#i18n translated URLs in sitemap

1 messages · Page 1 of 1 (latest)

pseudo iceBOT
#

Hi @tardy leaf. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Astro's sitemap integration automatically generates a sitemap based on your pages when you build your Astro project. This includes localized versions of your pages if you have configured i18n routing in your Astro project.

To link pages with translated URLs in the sitemap, you need to set up i18n routing in your Astro configuration. Here's an example of how to do this:

import { defineConfig } from "astro/config"
export default defineConfig({
  i18n: {
    defaultLocale: "en",
    locales: ["en", "de"],
  }
})

In this example, English is set as the default locale, and German is added as an additional locale. This means that Astro will generate pages for both English and German versions of your site.

Then, organize your content folders with localized content by language. Your folder names must match the items in locales exactly, and your folder organization must match the URL paths chosen for your routing.

* Directorysrc
  + Directorypages
    - about.astro
    - index.astro
    - Directoryde
      * about.astro
      * index.astro

In this example, there are English versions of the about and index pages at the root of the /pages/ directory, and German versions of these pages in the /de/ directory.

Astro's sitemap integration will then generate a sitemap that includes both the English and German versions of your pages, with the correct URLs for each version.

For more information, refer to the Astro documentation on i18n routing (https://docs.astro.build/en/guides/internationalization#configure-i18n-routing) and the Astro documentation on the sitemap integration (https://docs.astro.build/en/guides/integrations-guide/sitemap).

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: