next-forge automatically generates the 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

The system first scans the app directory to collect all page routes:

  1. Reads all directories in the app folder
  2. Filters out:
    • Directories starting with underscore (_) which are typically internal/private routes
    • Directories starting with parentheses (() which are usually Next.js route groups
  3. Uses the remaining directory names as valid page routes

Content Collection

The system then scans two content directories:

Blog Posts

  • Reads all files in the content/blog directory
  • Filters out:
    • Directory entries (only wants files)
    • Files starting with underscore
    • Files starting with parentheses
  • Removes the .mdx extension from filenames
  • Similarly scans the content/legal directory
  • Applies the same filtering rules as blog posts
  • Removes .mdx extensions

Sitemap Generation

The final sitemap is generated by combining all these routes:

  1. Adds the base URL as the root entry
  2. Adds all page routes prefixed with the base URL
  3. Adds all blog posts under the blog/ path
  4. Adds all legal pages under the legal/ path

Each sitemap entry includes:

  • A full URL (combining the base URL with the route)
  • A lastModified timestamp (set to the current date)

The sitemap is automatically regenerated during each build, ensuring it stays up to date with your content.