In general the sitemap setup is based on the Next.js sitemap documentation.

GraphQL Query

There is a specific GraphQL query in the sitemap.ts script that fetches all the models and their slugs: src/graphql/Sitemap.graphql. This needs to be updated for each project.

Custom Utilities

There are some custom utilities in the base sitemap.ts:

  • getSitemapEntry - Takes a slug or slugs (for projects with translated slugs, e.g. Nordstan) and returns a sitemap entry with the proper alternates

  • getAlternates - Takes the same as above, but also all but the “base locale” and generates the alternates for the sitemap entry.

  • getNestedSlug - Takes an array of slugs with locale and value and returns a single slug object with the slug compounded.

    getNestedSlug([{ locale: "en", value: "news" }, { locale: "en", value: data.id }])
    // returns `{ locale: "en", value: "news/123" }`

    Using these, the script goes through all the models and generates the sitemap entries.

Deployment

The sitemap is deployed to the website as a static file, and is therefore automatically updated when the website is deployed.