Docly Developers
DocsUpdated 23 Oct 2026

Example of dynamic sitemap.xml file

This example generates a dynamic sitemap.xml file

Sitemap.xml.hash

Remember to add .hash to your filename. You can retrieve the file without .hash at the end - the server adds it automatically.

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    #{
            let s = request.siteUrl.trim("/");
        // getFiles returns every file in the folder, also .hash files. Leave out code files,
        // and adjust the filter to the schemas your pages use.
        var isPage = (f) => f.fileschema != "Code File";
    }#
    #for(var folder of docly.getFolders("/")) {#
    <url>
        <loc>#docly.htmlEncode(s + folder.Url)#</loc>
        <lastmod>#docly.format(folder.LastModified, "yyyy-MM-dd")#</lastmod>
        <changefreq>monthly</changefreq>
        <priority>1</priority>
    </url>
    #}#
    #for(var file of docly.getFiles("/").filter(isPage)) {#
    <url>
        <loc>#docly.htmlEncode(s + file.Url)#</loc>
        <lastmod>#docly.format(file.LastModified, "yyyy-MM-dd")#</lastmod>
        <changefreq>monthly</changefreq>
        <priority>1</priority>
    </url>
    #}#
</urlset>

The sitemap namespace is http://www.sitemaps.org/schemas/sitemap/0.9 - with http, not https; it is an identifier, not a link. The URLs are XML-escaped with docly.htmlEncode(). A sitemap must not list URLs that redirect.