next-sitemap icon indicating copy to clipboard operation
next-sitemap copied to clipboard

Please explain how I can use this library

Open willhama opened this issue 1 year ago • 5 comments

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

http://localhost:3000/sitemap-0.xml

sitemap-0.xml

http://localhost:3000/opengraph-image.jpg2024-06-24T12:47:00.408Zdaily0.7 http://localhost:3000/twitter-image.jpg2024-06-24T12:47:00.409Zdaily0.7 `

Thank you very much upfront for your support.

willhama avatar Jun 24 '24 12:06 willhama

Same issue here, using latest version of nextjs (app router), we also just get an empty sitemap...

Have followed the instructions in the docs.

ollebergkvist avatar Jul 02 '24 20:07 ollebergkvist

Closing this issue due to inactivity.

github-actions[bot] avatar Sep 01 '24 04:09 github-actions[bot]

Same issue.

LZL0 avatar Sep 01 '24 18:09 LZL0

same issue

jamesryan-dev avatar Sep 04 '24 21:09 jamesryan-dev

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
  • 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-sitemap to 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.

BiBzz avatar Sep 23 '24 22:09 BiBzz

same issue

topwood avatar Oct 21 '24 08:10 topwood

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) };

IsDyh01 avatar Dec 17 '24 02:12 IsDyh01

Closing this issue due to inactivity.

github-actions[bot] avatar Feb 15 '25 04:02 github-actions[bot]

still same error. someone help.

akash3gtm avatar Mar 18 '25 14:03 akash3gtm

Same issue here

// next-sitemap.config.js module.exports = { siteUrl: process.env.NEXT_PUBLIC_API_URL, generateRobotsTxt: true, }

┌───────────────┬────────┐ │ (index) │ Values │ ├───────────────┼────────┤ │ indexSitemaps │ 1 │ │ sitemaps │ 0 │ └───────────────┴────────┘

kurtisdunn avatar Apr 08 '25 08:04 kurtisdunn