Next.js sitemap
Found out that my posts were not indexed by Google.
Search with site:https://minho42.com
didn't show all posts but only few pages.
Confirmed above with URL inspection from Google Search Console
Here's how I generate a sitemap for this blog (Next.js on Netlify Cloudflare) using next-sitemap
Paste below to next-sitemap.config.js
Adding postbuild command to package.json
worked locally
and generated following files in /public/
- robots.txt
- sitemap.xml
- sitemap-0.xml
However, this didn't work on Netlify as is, and an easy way to fix this was just to add the above postbuild
command inside the build
command like so
Note
If you are using Cloudflare Pages, make sure to change
Settings/Builds & deployments/Build configuration
as above build script instead of preset build command Cloudflare gives you when you selectFramework preset: Next.js (Static HTML Export)
Done.