Google is unhappy with generated sitemap

I just started with zola (0.8.0) and it works fine after a little reading. However, I generated my webpages and want to tell google about all pages by using the generated sitemap. This does not work, as I include the protocol in my base url, which gets https%3A due to urlencode.
Further is google not happy with xmlns https://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd, but it is happy with https://www.sitemaps.org/schemas/sitemap/0.9/.
The namespace I can easily fix with a own sitemap.xml like so:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9">
    {% for sitemap_entry in entries %}
        <url>
           
            <loc>{{ sitemap_entry.permalink |  urlencode | safe }}</loc>
            {% if sitemap_entry.date %}
                <lastmod>{{ sitemap_entry.date }}</lastmod>
            {% endif %}
        </url>
    {% endfor %}
</urlset>

I could also remove the urlencode, but imho it is necessary there, it should just ignore the :// between protocol and domain.
However, I have by now no idea how to do that properly.

Yep this is going to be fixed in the next version.

If your links don’t have special characters like &, you can remove the urlencode without any issues.

I have also opened https://github.com/servo/rust-url/issues/540 to implement the urlencoding in rust-url (which urlencode uses) directly otherwise I’ll have to implement it manually in Tera.

1 Like

Thank you for fast respone & explanation!

With all of these, I don’t understand why safe is being used at all. And then why do you even need urlencode? I would not expect URL encoding to be necessary in such a position.

The next branch uses XML escape instead