Minor Changes
-
#14285
bedc31b
Thanks @jdcolombo! - Adds a new configuration optionnamespaces
for 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
namespaces
option allows you to configurenews
,xhtml
,image
, andvideo
namespaces 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: false
in 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:video
namespace:<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="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>