Skip to content

Conversation

@mattyoho
Copy link
Contributor

@mattyoho mattyoho commented May 5, 2025

Changes

This adds a configuration option for the @astrojs/sitemap integration for setting the base filename for the generated sitemap XML files.

Impact on existing users

The new configuration setting is defaulted to a value that matches current behavior so that existing users won't be impacted.

Use case

Scenario: Astro is chosen for adding informational content pages for an existing product website at a set of top-level content categories, e.g., Docs, Blog, and Changelog. The content verticals need to be hosted on the root domain at /docs, /blog, and /changelog, respectively.

E.g., the Docs URL will be https://example.com/docs.

Problem: Currently, the generated sitemap files want to live at https://example.com/sitemap-index.xml and https://example.com/sitemap-{n}.xml, which will potentially conflict with an existing sitemap.xml for the root domain.

Solution: Add a config setting to change the generated filename so that the files can be integrated into a pre-existing sitemap-index.xml via other external tooling.

// https://astro.build/config
export default defineConfig({
  site: "https://example.com",
  integrations: [
    sitemap({
      filenameBase: "content-sitemap",
    }),
  ],
});

Testing

A test was added to the relevant test file. The change was also tested in a live Astro app using a local build of the integration package.

Docs

Documentation for the setting could / should be added to the related guide. Initial suggested changes PR has been opened here: withastro/docs#11614.

/cc @withastro/maintainers-docs for feedback!

@changeset-bot
Copy link

changeset-bot bot commented May 5, 2025

🦋 Changeset detected

Latest commit: d0cb2a6

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: integration Related to any renderer integration (scope) label May 5, 2025
mattyoho added a commit to mattyoho/docs that referenced this pull request May 5, 2025
mattyoho added a commit to mattyoho/docs that referenced this pull request May 5, 2025
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

The feature seems reasonable, simple enough and easy to understand. Thank you also for sending a PR to docs. I will ask docs to review the docs PR, in the meantime can you review the changeset?

'@astrojs/sitemap': minor
---

Allow configuring sitemap filenames generated by `@astro/sitemap`
Copy link
Member

Choose a reason for hiding this comment

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

Changesets are meant to document and show new features. In your case, you want to explicitly discuss the new feature you're adding, why it was added, and how users can use it (code snippet). It's a minimal version of the docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback, @ematipico. 🙂 I gave it a try in d0cb2a6, and will be happy to incorporate further review!

@mattyoho mattyoho requested a review from ematipico May 8, 2025 16:24
@ematipico ematipico merged commit 90293de into withastro:main May 8, 2025
14 checks passed
@astrobot-houston astrobot-houston mentioned this pull request May 8, 2025
openscript pushed a commit to openscript/astro that referenced this pull request Sep 12, 2025
…ntegration (withastro#13753)

* Allow configuring the generated sitemap filenames

* Add `filenameBase` to `@astro/sitemap` changeset

* Add more detail based on review feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: integration Related to any renderer integration (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants