Replace the sitemap page with Yoast-style XML sitemaps: an index, one sitemap per kind of page, styled tables
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Shows the sitemap index and each sitemap as a plain table in the browser. Search engines read the XML and ignore this file. -->
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:sm="http://www.sitemaps.org/schemas/sitemap/0.9"
|
||||
xmlns:xhtml="http://www.w3.org/1999/xhtml"
|
||||
exclude-result-prefixes="sm xhtml">
|
||||
<xsl:output method="html" encoding="UTF-8" indent="yes"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<meta name="robots" content="noindex, follow"/>
|
||||
<title>XML Sitemap</title>
|
||||
<style>
|
||||
body { margin:0; background:#fff; color:#444; font:13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
|
||||
#content { max-width:1000px; margin:0 auto; padding:24px 16px 48px; }
|
||||
h1 { margin:0 0 8px; font-size:24px; font-weight:600; color:#222; }
|
||||
p.desc { margin:0 0 4px; color:#555; }
|
||||
p.desc a { color:#0073aa; }
|
||||
p.count { margin:16px 0 12px; color:#555; }
|
||||
table { width:100%; border-collapse:collapse; border:1px solid #e5e5e5; }
|
||||
th { padding:8px 10px; background:#0073aa; color:#fff; text-align:left; font-weight:600; }
|
||||
td { padding:7px 10px; border-bottom:1px solid #eee; vertical-align:top; }
|
||||
tr:nth-child(even) td { background:#f6f8fa; }
|
||||
td a { color:#0073aa; text-decoration:none; word-break:break-all; }
|
||||
td a:hover { text-decoration:underline; }
|
||||
td.n, th.n { width:40px; color:#888; }
|
||||
td.date { width:160px; white-space:nowrap; }
|
||||
td.langs a { margin-right:6px; text-transform:uppercase; font-size:11px; font-weight:600; }
|
||||
@media (max-width:640px) { .hide-sm { display:none; } }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
<h1>XML Sitemap</h1>
|
||||
<p class="desc">This is an XML Sitemap, meant for consumption by search engines.</p>
|
||||
<p class="desc">You can find more information about XML sitemaps on <a href="https://www.sitemaps.org/" rel="noopener">sitemaps.org</a>.</p>
|
||||
<xsl:apply-templates select="sm:sitemapindex | sm:urlset"/>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="sm:sitemapindex">
|
||||
<p class="count">This XML Sitemap Index file contains <strong><xsl:value-of select="count(sm:sitemap)"/></strong> sitemaps.</p>
|
||||
<table>
|
||||
<thead><tr><th class="n">#</th><th>Sitemap</th><th>Last Modified</th></tr></thead>
|
||||
<tbody>
|
||||
<xsl:for-each select="sm:sitemap">
|
||||
<tr>
|
||||
<td class="n"><xsl:value-of select="position()"/></td>
|
||||
<td><a href="{sm:loc}"><xsl:value-of select="sm:loc"/></a></td>
|
||||
<td class="date"><xsl:value-of select="sm:lastmod"/></td>
|
||||
</tr>
|
||||
</xsl:for-each>
|
||||
</tbody>
|
||||
</table>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="sm:urlset">
|
||||
<p class="count">This XML Sitemap contains <strong><xsl:value-of select="count(sm:url)"/></strong> URLs. <a href="/sitemap.xml">← Sitemap Index</a></p>
|
||||
<table>
|
||||
<thead><tr><th class="n">#</th><th>URL</th><th class="hide-sm">Languages</th><th>Last Mod.</th></tr></thead>
|
||||
<tbody>
|
||||
<xsl:for-each select="sm:url">
|
||||
<tr>
|
||||
<td class="n"><xsl:value-of select="position()"/></td>
|
||||
<td><a href="{sm:loc}"><xsl:value-of select="sm:loc"/></a></td>
|
||||
<td class="langs hide-sm">
|
||||
<xsl:for-each select="xhtml:link[@hreflang != 'x-default'][@href != current()/sm:loc]">
|
||||
<a href="{@href}"><xsl:value-of select="@hreflang"/></a>
|
||||
</xsl:for-each>
|
||||
</td>
|
||||
<td class="date"><xsl:value-of select="sm:lastmod"/></td>
|
||||
</tr>
|
||||
</xsl:for-each>
|
||||
</tbody>
|
||||
</table>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
Reference in New Issue
Block a user