Skip to content

Conversation

jdcolombo
Copy link

This pull request adds documentation for the new namespaces configuration option to the sitemap integration guide. The update explains the purpose, type, and default values for this option, and provides a usage example.

Sitemap integration documentation update:

  • Added a section describing the namespaces option, including its type, default values, and its role in controlling which XML namespaces are included during sitemap generation.
  • Provided a code example in astro.config.mjs showing how to configure the namespaces option for the sitemap integration.

Updated docs for withastro/astro#14285

Related issues & labels (optional)

  • Closes #
  • Suggested label:

Copy link

netlify bot commented Sep 1, 2025

Deploy Preview for astro-docs-2 ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 8493446
🔍 Latest deploy log https://app.netlify.com/projects/astro-docs-2/deploys/68b953bad72ea20008b8ec91
😎 Deploy Preview https://deploy-preview-12250--astro-docs-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@astrobot-houston
Copy link
Contributor

astrobot-houston commented Sep 1, 2025

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
en/guides/integrations-guide/sitemap.mdx Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@astrobot-houston
Copy link
Contributor

Hello! Thank you for opening your first PR to Astro’s Docs! 🎉

Here’s what will happen next:

  1. Our GitHub bots will run to check your changes.
    If they spot any broken links you will see some error messages on this PR.
    Don’t hesitate to ask any questions if you’re not sure what these mean!

  2. In a few minutes, you’ll be able to see a preview of your changes on Netlify 🥳.

  3. One or more of our maintainers will take a look and may ask you to make changes.
    We try to be responsive, but don’t worry if this takes a few days.

@ascorbic ascorbic added add new content Document something that is not in docs. May require testing, confirmation, or affect other pages. merge-on-release Don't merge this before the feature is released! (MQ=approved but WAIT for feature release!) labels Sep 1, 2025
Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding these docs @jdcolombo ! I've suggested some ideas for slight language polishing to make this more in the style of Astro docs. And, I'd love for you to help provide a bit of guidance on when/why someone would use this to help the reader understand/decide when this might be right for them!

**Type:** `{ news?: boolean; xhtml?: boolean; image?: boolean; video?: boolean; }`
**Default:** `{ news: true, xhtml: true, image: true, video: true }`

Controls which XML namespaces are included in the sitemap generation.
Copy link
Member

@sarah11918 sarah11918 Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a sentence here that explains why someone might want to do this? (See the other entries on this page like customPages)

I can see from your implementation PR that you have said "This allows users to exclude unused namespaces like xmlns:news for cleaner sitemap files." Is that the main practical reason to have this option? These are namespaces that Astro would otherwise include, but now we have a configuration to NOT include them? And, is "looking cleaner" the advantage, or is there an associated performance advantage to having less included in the XML? Are there negative consequences they are trying to avoid? Is this personal preference? How do they decide?

Also, just more for my own understanding, is there a particular reason you've chosen these 4 options? Are there more that might eventually be added? In some cases, we'd even make separate namespace.video entries with a smaller sub section for each one. I think we can get away without that here, but we may consider doing that at some point, especially if there are enough of them that just looking at the type to figure out which ones are available seems a little difficult to read.

I think you have nicely describe what this does, but our docs often try to have a tiny bit of the why so that people know when they might choose to use this config option!

Also, there is no standard set of XML namespaces, I believe? But, there's probably a list of ones that are generated by Astro by default (otherwise, why would we need a PR to allow you to exclude some of them?) I'm assuming that there are some/more that are NOT configurable to be removed? I don't know that we need to list them all, but it might be more appropriate to describe this feature as namespaces that are excluded, not included! (Since there are more included by default that you do not set and cannot explicitly include?) Something maybe like this for a first sentence (but make this accurate):

An object of XML namespaces to exclude from the generated sitemap.

What would you suggest here so that this entry sounds more like the other config options?

Copy link
Author

@jdcolombo jdcolombo Sep 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why someone would want to exclude namespaces:
The main practical reasons are:

  • Excluding unused namespaces reduces XML bloat
  • Smaller sitemap files are faster to parse by search engines
  • Some SEO analysis tools prefer minimal sitemaps without unused declarations
  • Particularly relevant for sites with very large sitemaps

Regarding the 4 namespace options:
These are the standard XML namespaces that Astro includes by default in sitemaps.

  • xmlns:news - Google News sitemaps
  • xmlns:xhtml - Multilingual/alternate language links
  • xmlns:image - Image sitemaps
  • xmlns:video - Video sitemaps

You're right that we could potentially add more namespaces in the future, and separate subsections might be worth considering as the list grows.

Suggested documentation revision:


### `namespaces`

<p>

**Type:** `{ news?: boolean; xhtml?: boolean; image?: boolean; video?: boolean; }` <br />
**Default:** `{ news: true, xhtml: true, image: true, video: true }` <br />
<Since v="3.6.0" pkg="@astrojs/sitemap" />
</p>

An object of XML namespaces to exclude from the generated sitemap.

Excluding unused namespaces can help create cleaner, more focused sitemaps that are faster for search engines to parse and use less bandwidth. For example, if your site doesn't have news content, videos, or multiple languages, you can exclude those namespaces to reduce XML bloat.

By default, all configurable namespaces  (`news`, `xhtml`, `image`, and `video`) are included in your generated sitemap XML. To exclude a namespace from your sitemap generation, add a `namespaces` configuration object and set individual options to `false`:

```js title="astro.config.mjs" ins={8-14}
import { defineConfig } from 'astro/config';
import sitemap from '@astrojs/sitemap';

export default defineConfig({
  site: 'https://example.com',
  integrations: [
    sitemap({
      // Only include image and video namespaces
      namespaces: {
        news: false,
        xhtml: false, 
        // image and video will be true by default
      }
    })
  ]
});

Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really happy with where this landed! Just some tiny polishing and this will be good to go! Now that we know what our docs will say, it's easier to present the feature in the changeset of the implementation PR, so I'll move there next! 🚀


Excluding unused namespaces can help create cleaner, more focused sitemaps that are faster for search engines to parse and use less bandwidth. For example, if your site doesn't have news content, videos, or multiple languages, you can exclude those namespaces to reduce XML bloat.

By default, all configurable namespaces (`news`, `xhtml`, `image`, and `video`) are included in your generated sitemap XML. To exclude a namespace from your sitemap generation, add a `namespaces` configuration object and set individual options to `false`:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
By default, all configurable namespaces (`news`, `xhtml`, `image`, and `video`) are included in your generated sitemap XML. To exclude a namespace from your sitemap generation, add a `namespaces` configuration object and set individual options to `false`:
By default, all configurable namespaces (`news`, `xhtml`, `image`, and `video`) are included in your generated sitemap XML. To exclude one or more of these namespaces from your sitemap generation, add a `namespaces` configuration object and set individual options to `false`:

Comment on lines +501 to +505
// Only include image and video namespaces
namespaces: {
news: false,
xhtml: false,
// image and video will be true by default
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Only include image and video namespaces
namespaces: {
news: false,
xhtml: false,
// image and video will be true by default
namespaces: {
news: false,
xhtml: false,

I think this code snippet works even without the comments! I had originally thought about keeping one or the other, but I'm not sure it's needed.


An object of XML namespaces to exclude from the generated sitemap.

Excluding unused namespaces can help create cleaner, more focused sitemaps that are faster for search engines to parse and use less bandwidth. For example, if your site doesn't have news content, videos, or multiple languages, you can exclude those namespaces to reduce XML bloat.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Excluding unused namespaces can help create cleaner, more focused sitemaps that are faster for search engines to parse and use less bandwidth. For example, if your site doesn't have news content, videos, or multiple languages, you can exclude those namespaces to reduce XML bloat.
Excluding unused namespaces can help create more focused sitemaps that are faster for search engines to parse and use less bandwidth. For example, if your site doesn't have news content, videos, or multiple languages, you can exclude those namespaces to reduce XML bloat.

I love this paragraph, thank you so much for adding it! I think we can stick to just "more focused" to keep this... more focused! 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add new content Document something that is not in docs. May require testing, confirmation, or affect other pages. merge-on-release Don't merge this before the feature is released! (MQ=approved but WAIT for feature release!)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants