Example of dynamic sitemap.xml file Last updated: 17. Jan 2024

This example generates a dynamic sitemap.xml file

Sitemap.xml.hash

Remember to add .hash to your filename. You can retreive the file without specifying .hash behind, it will automatically be added by the server.

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9">
    #{
        let s = request.siteUrl.trim("/");
    }#
    #for(var folder of getfolders("/")) {#
    <url>
        <loc>#{ write(s+folder.Url); }#</loc>
        <lastmod>#docly.format(folder.LastModified, "yyyy-MM-dd")#</lastmod>
        <changefreq>monthly</changefreq>
        <priority>1</priority>
    </url>
    #}#
    #for(var file of getfiles("/")) {#
    <url>
        <loc>#{ write(s+file.Url); }#</loc>
        <lastmod>#docly.format(file.LastModified, "yyyy-MM-dd")#</lastmod>
        <changefreq>monthly</changefreq>
        <priority>1</priority>
    </url>
    #}#
</urlset>