Skip to content

When deploying locales to separate domains, URLs in the sitemap do not use the specified domain #12013

Description

@danielclow

Have you read the Contributing Guidelines on issues?

Prerequisites

Description

I noticed that Google Search Console was not reading the sitemap for my second locale that I deploy to a separate domain. When I opened the sitemap file, I saw that the URLs in the sitemap all pointed to my first locale's domain.

For reference, sitemap is configured as follows, but I don't see any options that would affect this:

sitemap: {
  lastmod: 'datetime',
  changefreq: null,
  priority: null
},

Reproducible demo

No response

Steps to reproduce

To reproduce, have at least two locales and set up the following in docusaurus.config.js

const config = {
  ...
  url: 'https://your-primary-domain.com',
  baseUrl: '/',
  ...
  },
  i18n: {
    defaultLocale: 'locale1',
    locales: ['locale1', 'locale2'],
    localeConfigs: {
      'locale1': {
        ...
        baseUrl: '/',
        url: 'https://your-primary-domain.com',
      },
      'locale2': {
        ...
        baseUrl: '/',
        url: 'https://your-secondary-domain.com'
      },
    },
  },
...

Deploying these locales to your-primary-domain.com and your-secondary-domain.com works fine, but if you check the sitemap.xml in your-secondary-domain.com, you will find that each item (a element) lists a URL from your-primary-domain.com

Expected behavior

When deployed to separate domains, locales should have independent sitemaps that include only the pages within that domain.

Actual behavior

The sitemap for the second locale uses the first locale's domain. I assume it is actually using the domain specified outside of the i18n block, but I have to specify some domain there (in the url parameter).

Your environment

Use the feature introduced in 3.9.x where you can deploy locales to separate domains. The rest shouldn't matter.

Self-service

  • I'd be willing to fix this bug myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its executionstatus: needs triageThis issue has not been triaged by maintainers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions