sitemap for the website using Next.js’s built-in sitemap generation functionality (sitemap.ts). The generation process scans different directories in the project and creates sitemap entries for various types of content:
Page Collection
If you add new pages or change the routes of your marketing pages, you need to make sure the sitemap reflects these changes. You can find the configuration for the sitemap in theapps/web/config.ts:
apps/web/config.ts
Content Collection
The system scans these directories:Blog Posts
- Reads all files in the
content/blogdirectory - Removes the
.mdxextension from filenames
Docs Posts
- Reads all files in the
content/docsdirectory - Removes the
.mdxextension from filenames
Legal Pages
- Similarly scans the
content/legaldirectory - Removes
.mdxextensions
Sitemap Generation
The final sitemap is generated by combining all these routes:- Adds the base URL as the root entry
- Adds all page routes defined in the
getSitemapConfigobject - Adds all blog posts under the
blog/path - Adds all blog posts under the
docs/path - Adds all legal pages under the
legal/path
- A full URL (combining the base URL with the route)
- A
lastModifiedtimestamp (set to the current date)
There is one thing you need to pay attention to, whether you need to set the
VERCEL_PROJECT_PRODUCTION_URL environment variable, which will affect the domain of all URL in the sitemap. If your website is deployed on vercel, this variable will be automatically set to the domain name deployed by the project, and you can also manually set it to specify your domain name.For web application, it could be set like your-domain.com, The value does not include the protocol scheme https://.