Skip to main content

Sitemap

Overdog Starter doesn't include a pre-installed plugin for sitemap generation, as it's designed to allow developers to customize their fields and data for SEO. Instead, a Twig template is provided for generating a sitemap.

Sitemap Twig Template

The provided template/sitemap.xml.twig file generates an XML sitemap that you can submit to search engines to help them crawl and index your site more effectively. Below is the structure of the template:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   {# Homepage #}
   {% set home = craft.entries.section('singleHome').one() %}
   <url>
      <loc>{{ siteUrl }}</loc>
      <lastmod>{{ home.dateUpdated|date("c") }}</lastmod>
   </url>
   {# Entries - exclude sections and type in the query #}
   {% set allEntries = craft.entries()
      .uri(':notempty:')
      .all()
   %}
   {# Loop through entries #}
   {% for entry in allEntries %}
      <url>
         <loc>{{ entry.url }}</loc>
         <lastmod>{{ entry.dateUpdated|date("c") }}</lastmod>
      </url>
   {% endfor %}
</urlset>

This template will include your homepage and all other entries that have a non-empty URI. Each URL node contains the location (loc) and the last modified date (lastmod) of the page. This information helps search engines prioritize crawling based on the content update frequency.

By using this Twig template, you maintain complete control over what gets included in your sitemap and can customize it according to the unique needs of your project.