iamvishnusankar/next-sitemapを使う。
yarn add next-sitemap -D
next-sitemap.js
をプロジェクトルートに配置する。
staticサイトの場合、out
に吐き出されるので、outDir: './out'
に設定する。
(Static HTML Exportで確認)
module.exports = { siteUrl: 'https://example.com', generateRobotsTxt: true, sitemapSize: 7000, outDir: './out' }
package.json
を変更する。
... "scripts": { "build": "next build && next export", "postbuild": "next-sitemap" // 追記 } ...