Need a custom feature? We can help!

Sitemap Configuration

The sitemap configuration in StartupFast.dev allows you to control how search engines index your website's content. This guide explains how to configure your sitemap settings.

Basic Configuration

The sitemap configuration is managed in lib/configuration/seo/sitemapConfig.ts. Here's a basic example:

1export const sitemapConfig: SitemapConfiguration = {
2  defaultDomain: process.env.NEXT_PUBLIC_APP_URL!,
3  staticRoutes: [
4    { path: "/", changeFrequency: "monthly" },
5    { path: "/blog", changeFrequency: "weekly", priority: "0.8" },
6  ],
7  blogPosts: {
8    include: true,
9    url: "/blog",
10  },
11  // ... other sections
12};

Configuration Options

Default Domain

Set your application's base URL using the defaultDomain property. This should match your NEXT_PUBLIC_APP_URL environment variable:

1defaultDomain: process.env.NEXT_PUBLIC_APP_URL!;

Static Routes

Define static routes that should always be included in your sitemap:

1staticRoutes: [
2  {
3    path: "/", // URL path
4    changeFrequency: "monthly", // How often the page changes
5    priority: "0.8", // SEO priority (optional, defaults to 0.5)
6  },
7  // Add more static routes...
8];

Each static route can have:

  • path: The URL path (required)
  • changeFrequency: How often the page changes (optional, defaults to "monthly")
  • priority: SEO priority from 0.0 to 1.0 (optional, defaults to 0.5)

Dynamic Sections

The sitemap builder supports several dynamic sections that can be toggled on/off:

1blogPosts: {
2  include: true,  // Enable/disable blog posts in sitemap
3  url: "/blog"    // Base URL for blog posts
4},
5categories: {
6  include: true,
7  url: "/blog/categories"
8},
9authors: {
10  include: true,
11  url: "/blog/authors"
12},
13dashboard: {
14  include: true,
15  url: "/dashboard"
16}

Each section has:

  • include: Boolean flag to toggle inclusion in the sitemap
  • url: Base URL for that section

How It Works

The sitemap builder (lib/seo/sitemap-builder.ts) automatically:

  1. Includes all configured static routes

  2. Adds all blog posts (if enabled) with:

    • URL: /blog/[slug]
    • Last modified: Post date
    • Change frequency: "monthly"
    • Priority: 0.7
  3. Adds all category pages (if enabled) with:

    • URL: /blog/category/[category]
    • Change frequency: "monthly"
    • Priority: 0.5
  4. Adds all author pages (if enabled) with:

    • URL: /blog/author/[author]
    • Change frequency: "monthly"
    • Priority: 0.5

Example Configuration

Here's a complete example showing all available options:

1export const sitemapConfig: SitemapConfiguration = {
2  defaultDomain: process.env.NEXT_PUBLIC_APP_URL!,
3  staticRoutes: [
4    { path: "/", changeFrequency: "monthly" },
5    { path: "/blog", changeFrequency: "weekly", priority: "0.8" },
6    { path: "/about", changeFrequency: "monthly", priority: "0.6" },
7    { path: "/contact", changeFrequency: "yearly", priority: "0.5" },
8  ],
9  blogPosts: {
10    include: true,
11    url: "/blog",
12  },
13  categories: {
14    include: true,
15    url: "/blog/categories",
16  },
17  authors: {
18    include: true,
19    url: "/blog/authors",
20  },
21  dashboard: {
22    include: false, // Exclude dashboard from sitemap
23    url: "/dashboard",
24  },
25};

Best Practices

  1. Update Frequencies: Choose appropriate change frequencies:

    • always: For pages that change multiple times per day
    • hourly: For news sites or frequently updated content
    • daily: For active blogs or dynamic content
    • weekly: For regularly updated sections
    • monthly: For fairly static content
    • yearly: For very static content
    • never: For archived content
  2. Priorities: Use priorities wisely:

    • Homepage: 1.0
    • Main sections: 0.8
    • Blog posts: 0.7
    • Categories/Tags: 0.5
    • Less important pages: 0.3-0.4
  3. Environment Variables: Always set your NEXT_PUBLIC_APP_URL environment variable to ensure correct sitemap generation.

  4. Dynamic Content: Enable only the dynamic sections that are actually used in your application.