Sitemap improvements

The first code I made for a sitemap generator site and has additional information, the second code is generated by BSS.
Informing the priority, as well as the last modification made to the search engines helps a lot in the indexing of the pages, making these changes would be of great help for us who use the BSS to create and update our sites.

Sitemap Generator

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<!--  created with Free Online Sitemap Generator www.xml-sitemaps.com  -->
<url>
<loc>https://andresomeluz.com.br/dj-niteroi/niteroi.html</loc>
<lastmod>2021-12-29T22:19:23+00:00</lastmod>
<priority>1.00</priority>
</url>

BSS Sitemap

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
<loc>https://andresomeluz.com.br/dj-araruama/araruama.html</loc>
</url>
1 Like

I noticed this as well. I export a sitemap using BSS. Then I add the lastmod manually, and the priority manually. Any new pages, I’ll create a manual entry for.

I know it would be nice for BSS to generate lastmod, but generally you will export the whole project before uploading to your webserver, meaning the lastmod will always be the same, and even if you do export only a single page and a sitemap, the NEW sitemap will be wrong, so you’d be manually adding an entry to your original sitemap anyway.

I can definitely see a use for manually setting sitemap priority in BSS though.

+1 for me. I recently had to manually change a sitemap → adding priority, etc.

Ok, six months late to the party, but I have been experimenting with this tonight, here is my solution. Would be interesting to get feedback…

Note: this will NOT work if uploading to the bss server, or a server without php

On each page of your bss file you need to add three custom meta field as:

<meta name="cf" content="weekly">
<meta name="pr" content="0.5">
<meta name="lm" content="2022-10-11">

cf=change frequency - pr = priority and lm = lastmod

Then create a php file (updatesitemap.php) with the following:

<?php
 

$sitemapurl = "yoursitemapurl.xml";
$stripextension = "";//add .html or .php if you need to strip out extension to match canonical url

$string = simplexml_load_file($sitemapurl) or die("Error: Cannot create object");

$output = '<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
';

foreach ($string as $url) {

    if ($stripextension != "") {
        $loc = str_replace($stripextension, "", $url->loc);
    } else {
        $loc = $url->loc;
    }

    $tags = get_meta_tags($url->loc);

    $output .= '<url>
    <loc>' . $loc . '</loc>';

    if (isset($tags['cf'])) {
        $output .= '<changefreq>' .  $tags['cf'] . '</changefreq>';
    }

    if (isset($tags['pr'])) {
        $output .= '<priority>' .  $tags['pr'] . '</priority>';
    }

    if (isset($tags['lm'])) {
        $output .= '<lastmod>' .  $tags['lm'] . '</lastmod>';
    }

    $output .= '</url>';
}

$output .= '</urlset> ';

$myfile = fopen("newsitemap.xml", "w") or die("Unable to open file!");
fwrite($myfile, $output);
fclose($myfile);

echo ("New Sitemap has been generated");

?>

Then whenever you update a page in bss then update the content of lm to the current date, change your priority if you need to.

Then open updatesitemap.php in a browser window and it will generate a new sitemap.

1 Like

BSS only outputs the sitemap with the url, the original poster and others wanted it to produce a complete sitemap with last modified and priority fields to improve SEO.

With this when you edit your page,you can change the lastmod variable and then export as usual which will generate the simple sitemap.

Then running the php script will produce the new sitemap with the correct data.

Duh! My bad for not reading the posts before yours! I’ve deleted my prior post.