8

Adding a sitemap to Jekyll | Steve Fenton

 2 years ago
source link: https://www.stevefenton.co.uk/2022/07/adding-a-sitemap-to-jekyll/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Adding a sitemap to Jekyll

You don’t really need a plugin to add a sitemap to your Jekyll site. You can use this basic template and extend as required.

To give you control over whether a page appears in the sitemap, I’ve used an additional header in the front-yaml on each page. You can see below the additional date and sitemap properties that we’re going to use…

---
layout: page
title: My Page Title 
date: 2022-07-20
sitemap: true
---

This means we can just list relevant pages in a sitemap.xml file, like this. It’s just a basic example with the minimal required fields.

---
layout: null
---
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% assign pages = site.pages | where:"sitemap","true" %}{% for page in pages %}  <url>
    <loc>https://octopus.com/devops{{ page.url }}</loc>
    <lastmod>{{ page.date }}</lastmod>
  </url>
{% endfor %}
</urlset>

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK