mirror of
https://github.com/danpros/htmly.git
synced 2026-04-18 11:36:20 +05:30
Improve sitemap performance
Remove the archive per day in sitemap.archive.xml. With AI, blog with 10K posts is not rare in the near future.
This commit is contained in:
parent
25266da435
commit
b361d7de2e
3 changed files with 5 additions and 17 deletions
|
|
@ -125,7 +125,6 @@ sitemap.priority.post = "0.5"
|
||||||
sitemap.priority.static = "0.5"
|
sitemap.priority.static = "0.5"
|
||||||
sitemap.priority.category = "0.5"
|
sitemap.priority.category = "0.5"
|
||||||
sitemap.priority.tag = "0.5"
|
sitemap.priority.tag = "0.5"
|
||||||
sitemap.priority.archiveDay = "-1"
|
|
||||||
sitemap.priority.archiveMonth = "0.5"
|
sitemap.priority.archiveMonth = "0.5"
|
||||||
sitemap.priority.archiveYear = "0.5"
|
sitemap.priority.archiveYear = "0.5"
|
||||||
sitemap.priority.author = "0.5"
|
sitemap.priority.author = "0.5"
|
||||||
|
|
|
||||||
|
|
@ -198,12 +198,14 @@ if (empty($defaultFormat)) {
|
||||||
<p><?php echo i18n('Valid_values_range_from_0_to_1.0._See');?> <a target="_blank" href="https://www.sitemaps.org/protocol.html">https://www.sitemaps.org/protocol.html</a></p>
|
<p><?php echo i18n('Valid_values_range_from_0_to_1.0._See');?> <a target="_blank" href="https://www.sitemaps.org/protocol.html">https://www.sitemaps.org/protocol.html</a></p>
|
||||||
<?php foreach($array as $key => $value) {?>
|
<?php foreach($array as $key => $value) {?>
|
||||||
<?php if (stripos($key, 'sitemap.priority') !== false):?>
|
<?php if (stripos($key, 'sitemap.priority') !== false):?>
|
||||||
|
<?php if ($key !== 'sitemap.priority.archiveDay'):?>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="<?php echo $key;?>" class="col-sm-2 col-form-label"><?php echo $key;?></label>
|
<label for="<?php echo $key;?>" class="col-sm-2 col-form-label"><?php echo $key;?></label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input step="any" type="number" name="-config-<?php echo $key;?>" class="form-control" id="<?php echo $key;?>" value="<?php echo $value;?>">
|
<input step="any" type="number" name="-config-<?php echo $key;?>" class="form-control" id="<?php echo $key;?>" value="<?php echo $value;?>">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<?php endif;?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
|
|
|
||||||
|
|
@ -3001,13 +3001,10 @@ function sitemap_post_path($posts, $page = 1, $perpage = 0)
|
||||||
$post->date = strtotime($timestamp);
|
$post->date = strtotime($timestamp);
|
||||||
$post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($filepath)));
|
$post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($filepath)));
|
||||||
|
|
||||||
// The archive per day
|
// The archive per month
|
||||||
$post->archiveday = site_url() . 'archive/' . date('Y-m-d', $post->date);
|
|
||||||
|
|
||||||
// The archive per day
|
|
||||||
$post->archivemonth = site_url() . 'archive/' . date('Y-m', $post->date);
|
$post->archivemonth = site_url() . 'archive/' . date('Y-m', $post->date);
|
||||||
|
|
||||||
// The archive per day
|
// The archive per year
|
||||||
$post->archiveyear = site_url() . 'archive/' . date('Y', $post->date);
|
$post->archiveyear = site_url() . 'archive/' . date('Y', $post->date);
|
||||||
|
|
||||||
// The post URL
|
// The post URL
|
||||||
|
|
@ -3214,33 +3211,23 @@ function generate_sitemap($str)
|
||||||
|
|
||||||
} elseif ($str == 'archive.xml') {
|
} elseif ($str == 'archive.xml') {
|
||||||
|
|
||||||
$priorityDay = (config('sitemap.priority.archiveDay')) ? config('sitemap.priority.archiveDay') : $default_priority;
|
|
||||||
$priorityMonth = (config('sitemap.priority.archiveMonth')) ? config('sitemap.priority.archiveMonth') : $default_priority;
|
$priorityMonth = (config('sitemap.priority.archiveMonth')) ? config('sitemap.priority.archiveMonth') : $default_priority;
|
||||||
$priorityYear = (config('sitemap.priority.archiveYear')) ? config('sitemap.priority.archiveYear') : $default_priority;
|
$priorityYear = (config('sitemap.priority.archiveYear')) ? config('sitemap.priority.archiveYear') : $default_priority;
|
||||||
|
|
||||||
$posts = sitemap_post_path(null, 1, null);
|
$posts = sitemap_post_path(null, 1, null);
|
||||||
$day = array();
|
|
||||||
$month = array();
|
$month = array();
|
||||||
$year = array();
|
$year = array();
|
||||||
|
|
||||||
foreach ($posts as $p) {
|
foreach ($posts as $p) {
|
||||||
$day[] = $p->archiveday;
|
|
||||||
$month[] = $p->archivemonth;
|
$month[] = $p->archivemonth;
|
||||||
$year[] = $p->archiveyear;
|
$year[] = $p->archiveyear;
|
||||||
}
|
}
|
||||||
|
|
||||||
$day = array_unique($day, SORT_REGULAR);
|
|
||||||
$month = array_unique($month, SORT_REGULAR);
|
$month = array_unique($month, SORT_REGULAR);
|
||||||
$year = array_unique($year, SORT_REGULAR);
|
$year = array_unique($year, SORT_REGULAR);
|
||||||
|
|
||||||
$map .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
|
$map .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
|
||||||
|
|
||||||
if ($priorityDay !== '-1') {
|
|
||||||
foreach ($day as $d) {
|
|
||||||
$map .= '<url><loc>' . $d . '</loc><priority>' . $priorityDay . '</priority></url>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($priorityMonth !== '-1') {
|
if ($priorityMonth !== '-1') {
|
||||||
foreach ($month as $m) {
|
foreach ($month as $m) {
|
||||||
$map .= '<url><loc>' . $m . '</loc><priority>' . $priorityMonth . '</priority></url>';
|
$map .= '<url><loc>' . $m . '</loc><priority>' . $priorityMonth . '</priority></url>';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue