@maci
Next.js automatically generates a sitemap.xml file for your website during the build process. All you need to do is add a sitemap.xml
file to the public
directory of your Next.js project.
Here are the steps to add a sitemap.xml file to your Next.js project:
1 2 3 4 5 6 7 |
const withSitemap = require('next-sitemap')({ /* options */ }); module.exports = withSitemap({ /* Next.js config options */ }); |
1
|
npm install next-sitemap |
1
|
npm run build |
After running the build command, Next.js will generate a sitemap.xml file in the root directory of your project. You can check if the sitemap.xml file is working properly by navigating to http://localhost:3000/sitemap.xml
in your browser.