Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem generating a sitemap #6618

Closed
1 task
ljrodriguez1 opened this issue Mar 21, 2023 · 3 comments · Fixed by #6658
Closed
1 task

Problem generating a sitemap #6618

ljrodriguez1 opened this issue Mar 21, 2023 · 3 comments · Fixed by #6658
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)

Comments

@ljrodriguez1
Copy link

ljrodriguez1 commented Mar 21, 2023

What version of astro are you using?

2.1.2

Are you using an SSR adapter? If so, which one?

Vercel

What package manager are you using?

npm

What operating system are you using?

Linux, WSL2

What browser are you using?

Chrome

Describe the Bug

The bug i Am experiencing is with this minimal astro config

export default defineConfig({
  site: "https://example.com",
  base: "/blog",
  output: "static",
  adapter: vercel(),
  integrations: [
    sitemap(),
  ],
  trailingSlash: "never",
});

This produce 2 sitemap files, the first one is sitemap-index.xml

<?xml version="1.0" encoding="UTF-8"?><sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://example.com/sitemap-0.xml</loc></sitemap></sitemapindex>

Here we should have https://example.com/blog/sitemap-0.xml

then in the second file: sitemap-0.xml i have this:

<?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" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"><url><loc>https://sundes.com/blogpost/1</loc></url></urlset>

where i should have a url like https://sundes.com/blog/post/1

I think this is a bug in the plugin, i will try to fix this, but i am not sure if i could create a working PR for this

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-47cfzy?file=astro.config.mjs

Participation

  • I am willing to submit a pull request for this issue.
@matthewp matthewp added the - P3: minor bug An edge case that only affects very specific usage (priority) label Mar 24, 2023
@43081j
Copy link
Contributor

43081j commented Mar 24, 2023

if i run the repro locally it seems to work fine.

we get a sitemap-index.xml which has one entry: [...]/blog/sitemap-0.xml

that then has several /blog/blog/[...] entries (/blog/ twice in each one but that seems different to your problem)

maybe its just me though? could you try the repro again?

@andremralves
Copy link
Contributor

if i run the repro locally it seems to work fine.

I think it's because the 'trailingSlash: "never"' option is missing in the repro.

I tested locally and this error seems to occur when both base: "/something" and trailingSlash: "never" options are set. So the sitemap plugin generates a URL without the trailing slash for the base path.

I think I can solve this issue. If nobody is currently working to solve it, I would like to work on this issue.

@43081j
Copy link
Contributor

43081j commented Mar 25, 2023

@andremralves go for it, doesn't sound like anyone's on it

im gonna guess its some buggy concatenation in the sitemap integration, probably a good place to start. joining paths without a trailing slash to separate them

assuming depending on the node standard lib is fine - could maybe use path.join

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants