Skip to content

Add trailing slash to sitemap URLs#872

Open
jpurnell wants to merge 1 commit intotwostraws:mainfrom
jpurnell:fix/sitemap-trailing-slash
Open

Add trailing slash to sitemap URLs#872
jpurnell wants to merge 1 commit intotwostraws:mainfrom
jpurnell:fix/sitemap-trailing-slash

Conversation

@jpurnell
Copy link
Contributor

Summary

Ignite generates pages as directory/index.html, so the canonical served URL for each page includes a trailing slash (e.g., /library/ not /library). The sitemap was emitting URLs without the trailing slash, causing 301 redirects on hosts like GitHub Pages.

For example, the sitemap would contain:

<loc>https://example.com/library</loc>

But the actual page is served at https://example.com/library/, resulting in a 301 redirect. This means search engines follow an unnecessary redirect for every page in the sitemap.

This fix ensures sitemap <loc> URLs include a trailing slash to match the actual served URLs, avoiding the redirects.

  • Paths that already end in / (like the root /) are left unchanged
  • Only affects sitemap URL output — internal path storage is unchanged

Test plan

  • swift build passes
  • Verified existing tests still pass
  • Rebuild a site and confirm sitemap URLs now end in /

Ignite generates pages as directory/index.html, so the canonical URL
for each page includes a trailing slash (e.g. /library/ not /library).
The sitemap was emitting URLs without the trailing slash, causing 301
redirects on hosts like GitHub Pages that redirect /path to /path/.

This ensures sitemap <loc> URLs match the actual served URLs, avoiding
unnecessary redirects and improving SEO.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant