Sitemap blank page

Hello, I`m trying to make a sitemap of the web page.

I have created a sitemap.htm like the one in demo Theme (i`m using other theme).
Have and blueprint too, but when try to access a website/sitemap.xml just loading blank page.

I have created items in Sitemap.

Hello,

Did you set the sitemap url to be sitemap.xml ?

Did you change the page header to application/xml (using the ressource) component ?

Your page should looks like that :

url = "/sitemap.xml"
title = "Sitemap"

[resources]
headers[Content-Type] = "application/xml"

==

// Your sitemap code
1 Like

Hello,

Yep, here is my code

url = "/sitemap.xml"
title = "Sitemap"

[resources]
headers[Content-Type] = "application/xml"

[collection sitemap]
handle = "Site\Sitemap"
==
{% macro render_sitemap_item(item, reference, isRoot) %}
    {% import _self as nav %}
    {% set hideRootItem = isRoot and item.replace %}
    {% if reference.url and not hideRootItem %}
        <url>
            <loc>{{ reference.url }}</loc>
            <lastmod>{{ reference.mtime|date('c') }}</lastmod>
            <changefreq>{{ item.changefreq }}</changefreq>
            <priority>{{ item.priority }}</priority>

            {#- Multisite implementation -#}
            {% if reference.sites %}
                {% for site in reference.sites %}
                    <xhtml:link rel="alternative" hreflang="{{ site.locale }}" href="{{ site.url }}" />
                {% endfor %}
            {% endif %}
        </url>
    {% endif %}

    {#- Render child items -#}
    {% if reference.items %}
        {% for child in reference.items %}
            {{ nav.render_sitemap_item(item, child) }}
        {% endfor %}
    {% endif %}
{% endmacro %}
{% import _self as nav %}
<urlset
    xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
    xmlns:xhtml="https://www.w3.org/1999/xhtml"
    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"
>
    {% for item in sitemap %}
        {{ nav.render_sitemap_item(
            item,
            link(item.reference, { nesting: item.nesting, sites: true }),
            true
        ) }}
    {% endfor %}
</urlset>