Blogging structure with SEO markup
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
blog/sitemap.php

46 lines
1.6 KiB

<?php
/**
urlset structure
url:
loc: fully qualified url of page
lastmod: date of last change to page
- W3C DATETIME format (http://www.w3.org/TR/NOTE-datetime).
- Example: 2005-05-10, or 2005-05-10T17:33:30+08:00
changefreq: optional, one of
- always, hourly, daily, weekly, monthly, yearly, never
- value "always" should be used to describe documents that change each
time they are accessed. The value "never" should be used to describe
archived URLs.
priority: optional, relative to other pages, from 0.0 to 1.0
*/
header('Content-Type: text/xml; charset=utf-8');
$fileglob = glob('*.php');
$base = "{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['SERVER_NAME']}";
?>
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/sitemap.xsl"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd"
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php
foreach($fileglob as $file) {
if ($file === 'index.php') continue;
if ($file === 'sitemap.php') continue;
# $page = file_get_contents($file);
# $update = stat($file)->modified_date;
$file = basename($file, '.php');
$update = '2025-05-07';
?>
<url>
<loc><?= $base ?>/articles/<?= $file ?></loc>
<lastmod><?= $update ?></lastmod>
</url>
<?php
} // end foreach
?>
</urlset>