Help with sitemap.xml

Hello!

Website: https://www.lawfirmuk.net/

I want to make separate versions of xml sitemap for different language versions.

There will be a page https://www.lawfirmuk.net/sitemap.xml and it will have links to sitemaps for English, Russian, Chinese and Ukrainian versions. How can I solve this?

Hi @yulya6758656

Here is an example CMS page for a multilingual sitemap:

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

[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>

And the blueprint to accompany it:

uuid: 6743a1c3-3e57-4cfa-a886-e0c0a277fd71
handle: Site\Sitemap
type: structure
name: Sitemap
drafts: false
pagefinder: false

structure:
    maxDepth: 1

navigation:
    parent: settings
    icon: icon-sitemap
    description: Specify pages to appear in the sitemap for your website.
    category: CATEGORY_CMS

fields:
    reference:
        label: Reference
        type: pagefinder

    priority:
        label: Priority
        commentAbove: The priority of this URL relative to other URLs on your site.
        type: radio
        inlineOptions: true
        options:
            '0.1': '0.1'
            '0.2': '0.2'
            '0.3': '0.3'
            '0.4': '0.4'
            '0.5': '0.5'
            '0.6': '0.6'
            '0.7': '0.7'
            '0.8': '0.8'
            '0.9': '0.9'
            '1.0': '1.0'

    changefreq:
        commentAbove: How frequently the page is likely to change.
        label: Change Frequency
        type: radio
        inlineOptions: true
        options:
            always: Always
            hourly: Hourly
            daily: Daily
            weekly: Weekly
            monthly: Monthly
            yearly: Yearly
            never: Never

    nesting:
        label: Include nested items
        shortLabel: Nesting
        comment: Nested items could be generated dynamically by supported page references.
        type: checkbox

    replace:
        label: Replace this item with its generated children
        comment: Use this checkbox to push generated menu items to the same level with this item. This item itself will be hidden.
        type: checkbox
        column: false
        scope: false
        trigger:
            action: disable|empty
            field: nesting
            condition: unchecked

I hope this helps!

How does this works with a CMS page with dynamic categories?
CMS Page: /:category/:subcat/:slug

This is what I get in the sitemap output:
http://localhost:8888/website/default/default/post-title
http://localhost:8888/website/en/default/default/post-title

Check this post for the answer: How to internal linking to blog post - #2 by daft