{"timestamp":1791058400,"title":"Creating An Automatically Updating Sitemap In PureBlog","content":"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<\/a> by David Carr for it.\r\n\r\nBasically, 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:\r\n\r\n1) Make a file called sitemap-auto.php in content\/includes\/\r\n\r\n2) Make a custom route in settings\r\n\r\n``` \/sitemap-auto | \/content\/includes\/sitemap-auto.php ```\r\n\r\n3) Copy the code below or here<\/a>\r\n\r\n``` null]);\r\n\r\n?>\r\n\r\n
\r\n

Sitemap<\/h1>\r\n\r\n\";\r\n\r\nforeach ($files as $file) {\r\n if ($file !== \".\" && $file !== \"..\") {\r\n $name = pathinfo($file, PATHINFO_FILENAME);\r\n $path = $directory . '\/' . $file;\r\n $contents = file_get_contents($path);\r\n\r\n preg_match('\/^title:\\s*(.+)$\/m', $contents, $matches);\r\n\r\n $title = $matches[1] ?? pathinfo($file, PATHINFO_FILENAME);\r\n\r\n $url = '\/' . pathinfo($file, PATHINFO_FILENAME);\r\n\r\n echo '
  • 🛸 '\r\n . htmlspecialchars(trim($title))\r\n . '<\/a><\/li>';\r\n}\r\n}\r\necho \"<\/ul>\";\r\n?>\r\n\r\n<\/main>\r\n null]); ?>\r\n<\/body>\r\n<\/html>\r\n```\r\n4) Put it in \/content\/includes\/sitemap-auto.php\r\n\r\nYou're done :)\r\n\r\nThis will automatically update when a new file is in the pages list. You can find a live preview on my site here.<\/a>","description":"","status":"published","tags":"tech, tutorial, meta","date":"2026-09-20 14:38","layout":""}