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

generated XML contains dynamic route path #79

Open
FunctionDJ opened this issue Jan 18, 2021 · 2 comments
Open

generated XML contains dynamic route path #79

FunctionDJ opened this issue Jan 18, 2021 · 2 comments

Comments

@FunctionDJ
Copy link

This is an excerpt of the XML file i get:

<url>
  <loc>https://example.com/blog/foo</loc>
  <lastmod>2021-01-18</lastmod>
</url>
<url>
  <loc>https://example.com/blog/bar</loc>
  <lastmod>2021-01-18</lastmod>
</url>
<url>
  <loc>https://example.com/blog/[slug]</loc>
  <lastmod>2021-01-18</lastmod>
</url>
<url>
  <loc>https://example.com/blog</loc>
  <lastmod>2021-01-18</lastmod>
</url>

You can see the /blog/[slug] entry. I don't think this is intentional/correct since that's not a path a browser or crawler can access. Only the other 3 routes should be rendered.

Here is my scripts/sitemap-generator.js:

const sitemap = require("nextjs-sitemap-generator");

sitemap({
  baseUrl: "https://example.com",
  pagesDirectory: process.cwd() + "/.next/server/pages",
  targetDirectory: "out/"
});

console.log("✅ sitemap.xml generated!");

Since the site is fully static, i call this script using package.json:

{
  "scripts": {
    "dev": "next dev",
    "build": "next build && next export && npm run sitemap",
    "serve": "npm run build && serve ./out/",
    "start": "next start",
    "sitemap": "node scripts/sitemap-generator.js"
  }
}
@IlusionDev
Copy link
Owner

Which version are you using?

@FunctionDJ
Copy link
Author

"nextjs-sitemap-generator": "^1.3.0",

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

No branches or pull requests

2 participants