---
title: Creating An Automatically Updating Sitemap In PureBlog
slug: creating-an-automatically-updating-sitemap-in-pureblog
date: 2026-09-20 14:38
status: published
tags: [tech, tutorial, meta]
description:
---
I wanted to not have to update my sitemap every time I made a new page, so here's my VERY basic automatically updating Sitemap page for Pureblog. I altered THIS CODE SNIPPET by David Carr for it.
Basically, this takes a list of the files in your pureblog/content/pages directory and retrieves it for the page with its title. Note that I'm using my dockerized version so please edit accordingly. When I learn more PHP, I will be updating this with categories and alphabetical sorting. For now though:
1) Make a file called sitemap-auto.php in content/includes/
2) Make a custom route in settings
``` /sitemap-auto | /content/includes/sitemap-auto.php ```
3) Copy the code below or here
``` null]);
?>
Sitemap
";
foreach ($files as $file) {
if ($file !== "." && $file !== "..") {
$name = pathinfo($file, PATHINFO_FILENAME);
$path = $directory . '/' . $file;
$contents = file_get_contents($path);
preg_match('/^title:\s*(.+)$/m', $contents, $matches);
$title = $matches[1] ?? pathinfo($file, PATHINFO_FILENAME);
$url = '/' . pathinfo($file, PATHINFO_FILENAME);
echo '🛸 '
. htmlspecialchars(trim($title))
. '';
}
}
echo "";
?>
null]); ?>