Install

Terminal
$ roq add plugin:sitemap

Usage

Easily create a sitemap for your site: sitemap.xml for search engines, and an HTML page for visitors.

XML sitemap

Create a new sitemap file:

{#include fm/sitemap.xml /}

Browse http://localhost:8080/sitemap.xml to verify.

HTML sitemap

Create a new sitemap page, e.g. sitemap.html, with a layout:

---
title: Sitemap
layout: page
---
{#include fm/sitemap.html /}

This produces a <nav class="roq-sitemap"> with a Pages group for your loose pages, followed by one group per collection (documents in the collection's natural order, newest first). Groups with nothing to show are left out, and the page holding the include never links to itself.

<nav class="roq-sitemap">
  <section class="roq-sitemap-group roq-sitemap-pages">
    <h2>Pages</h2>
    <ul>
      <li><a href="/">Home</a></li>
      <li><a href="/about/">About</a></li>
    </ul>
  </section>
  <section class="roq-sitemap-group roq-sitemap-collection" data-collection="posts">
    <h2>Posts</h2>
    <ul>
      <li><a href="/posts/hello-roq/">Hello Roq</a></li>
    </ul>
  </section>
</nav>

The default theme styles it out of the box. To customize it, target the .roq-sitemap class, or a specific group with .roq-sitemap-pages, .roq-sitemap-collection or [data-collection="posts"].

Excluding pages

Use sitemap: false in the FM data to keep a page or a document out of both sitemaps. The page holding the HTML include is left out of its own listing, but still appears in sitemap.xml so search engines can index it.

no-index-all: true keeps a page out of both sitemaps and of every other index at once (llms.txt, search, and it defaults the robots meta tag to noindex). Set sitemap: true on the same page to list it in the sitemaps anyway.

Last modified date

Each <lastmod> uses the last-modified-at FM data when set, otherwise it is computed depending on quarkus.roq.sitemap.last-modified:

  • git (default): the date of the last git commit touching the file (the file system date for uncommitted files)
  • fs: the file system last modification date
  • none: not computed, the page date is used

To keep dev mode fast on large sites, the plugin uses fs in dev mode. To use git dates in dev mode too:

%dev.quarkus.roq.sitemap.last-modified=git