引用元 : Next.js に next-sitemap を導入して超手軽にサイトマップ sitemap.xml を生成しよう | fwywd(フュード)powered by キカガク
npm install --save-dev next-sitemap
sitemap.config.js
// config for next-sitemap
module.exports = {
siteUrl: 'https://YOUR-SITE.com/',
generateRobotsTxt: true,
sitemapSize: 7000,
outDir: './public',
};
package.json
"scripts": {
"build": "next build && next-sitemap --config sitemap.config.js",
},
npm run build
/public/sitemap.xml が生成されるので Google Search Console からGoogleに読み込ませます
.gitignore
# next-sitemap が自動生成するファイルは除外する
/public/sitemap.xml
/public/robots.txt