🍿 Minor Changes
-
#14285
bedc31bThanks @jdcolombo! - Adds a new configuration optionnamespacesfor more control over XML namespaces used in sitemap generationExcluding unused namespaces can help create cleaner, more focused sitemaps that are faster for search engines to parse and use less bandwidth. If your site doesn’t have news content, videos, or multiple languages, you can exclude those namespaces to reduce XML bloat.
The
namespacesoption allows you to configurenews,xhtml,image, andvideonamespaces independently. All namespaces are enabled by default for backward compatibility and no change to existing projects is necessary. But now, you can choose to streamline your XML and avoid unnecessary code.For example, to exclude the video namespace from your sitemap, set
video: falsein your configuration:astro.config.mjs import { sitemap } from '@astrojs/sitemap';export default {integrations: [sitemap({namespaces: {video: false,// other namespaces remain enabled by default}})]};The generated XML will not include the
xmlns:videonamespace:<?xml version="1.0" encoding="UTF-8"?><urlsetxmlns="http://www.sitemaps.org/schemas/sitemap/0.9"xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"xmlns:xhtml="http://www.w3.org/1999/xhtml"xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"><!-- ... --></urlset>