Please explain how I can use this library
Is your feature request related to a problem? Please describe. The documentation is lacking quite a few open questions to me. How can I use this library? When do I run the postscript command? What's the best practice? Do I put it in my CICD pipeline? How can I test the command locally? What the expected output?
Describe the solution you'd like I want a clear description of how this library can be executed and what is the expected outcome.
Describe alternatives you've considered I have considered writing the sitemap by myself.
Additional context
Currently I am running pnpm run build and it creates basically an empty sitemap:
` sitemap.xml
sitemap-0.xml
Thank you very much upfront for your support.
Same issue here, using latest version of nextjs (app router), we also just get an empty sitemap...
Have followed the instructions in the docs.
Closing this issue due to inactivity.
Same issue.
same issue
Hi @themataleao, For your questions :
-
How can I use this library?
- Since you seem to use PNPM :
pnpm install next-sitemap - Create config file. For example :
module.exports = { siteUrl: "https://yourdomain.com", generateRobotsTxt: true, };- Add postbuild command in package.json
"scripts": { "dev": "next dev -H 0.0.0.0", "build": "next build", "postbuild": "next-sitemap", "start": "next start", "lint": "next lint" },- Generate robots.txt and sitemap.xml with
pnpm postbuild
- Since you seem to use PNPM :
- When do I run the postscript command? When you want generate robots.txt and sitemap.xml. Locally or during CI/CD
- What's the best practice? No idea at all. I 'm currently doing it locally and push them to make sure they're perfectly up to date
-
How can I test the command locally?
You can use
npx next-sitemapto focus locally. - What the expected output? At least 2 sitemaps and 1 optionally generated robots.txt (robots.txt generation isn't shown in console, but it's here)
✅ [next-sitemap] Generation completed
┌───────────────┬────────┐
│ (index) │ Values │
├───────────────┼────────┤
│ indexSitemaps │ 1 │
│ sitemaps │ 1 │
└───────────────┴────────┘
-----------------------------------------------------
SITEMAP INDICES
-----------------------------------------------------
○ https://yourdomain.com/sitemap.xml
-----------------------------------------------------
SITEMAPS
-----------------------------------------------------
○ https://yourdomain.com/sitemap-0.xml
I hope it'll help! Have a great day.
same issue
hi @BiBzz ,I am using this library, and when I execute the npx next-sitemap command, it generates an empty sitemap file。
next: 14.2.3 next-sitemap: 4.2.3
┌───────────────┬────────┐ │ (index) │ Values │ ├───────────────┼────────┤ │ indexSitemaps │ 1 │ │ sitemaps │ 0 │ └───────────────┴────────┘
next-sitemap.config.js module.exports = { siteUrl: 'localhost:3000', generateRobotsTxt: true, // (optional) };
Closing this issue due to inactivity.
still same error. someone help.
Same issue here
// next-sitemap.config.js module.exports = { siteUrl: process.env.NEXT_PUBLIC_API_URL, generateRobotsTxt: true, }
┌───────────────┬────────┐ │ (index) │ Values │ ├───────────────┼────────┤ │ indexSitemaps │ 1 │ │ sitemaps │ 0 │ └───────────────┴────────┘