Skip to content

Commit

Permalink
Add an example xslt stylesheet and instructions to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jadwigo committed Mar 13, 2018
1 parent 63aaa3d commit e6957ac
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Expand Up @@ -43,3 +43,14 @@ sitemapXml:

Note, if you have a ContentType with the property `searchable: false`, that
content type will be ignored.

## Sitemap stylesheets

You can customize the sitemap with an xslt stylesheet if you copy the `templates/sitemap_xml.twig`
file and the `web/sitemap.xsl` file to your theme directory and by adding the xsl-stylesheet declaration
after the xml declaration so the first two lines of the `themes/{yourthemename}/sitemap_xml.twig` look like:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="{{ paths.theme }}/sitemap.xsl"?>
```
104 changes: 104 additions & 0 deletions web/sitemap.xsl
@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:s="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:n="http://www.google.com/schemas/sitemap-news/0.9"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>XML Sitemap</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body {
font-family: Helvetica, Arial, sans-serif;
font-size: 13px;
color: #545353;
margin: 0 auto;
width: 80%;
min-width: 60em;
}
table {
border: none;
border-collapse: collapse;
}
tr:nth-child(odd) {
background-color: #eee;
}
tbody tr:hover {
background-color: #ccc;
}
tbody tr:hover td,
tbody tr:hover td a {
color: #000;
}
p {
margin: 10px 3px;
line-height: 1.3em;
}
a {
color: #da3114;
text-decoration: none;
}
a:visited {
color: #777;
}
a:hover {
text-decoration: underline;
}
td {
font-size:11px;
}
th {
text-align:left;
padding-right:30px;
font-size:11px;
}
thead th {
border-bottom: 1px solid #000;
}
</style>
</head>
<body>
<div id="content">
<h1>XML Sitemap</h1>
<p>
Generated by the <a href="http://bolt.cm/">Bolt</a> sitemap extension, this is an XML Sitemap, meant for consumption by Google.
</p>
<p>
You can find more information about XML News sitemaps <a href="http://www.google.com/support/webmasters/bin/answer.py?hl=en&amp;answer=74288">here</a>.
</p>
<p>
This sitemap contains <xsl:value-of select="count(s:urlset/s:url)"/> URLs.
</p>
<table id="sitemap" cellpadding="3">
<thead>
<tr>
<th width="50%">Title</th>
<th width="15%">Publication Date</th>
</tr>
</thead>
<tbody>
<xsl:for-each select="s:urlset/s:url">
<tr>
<td>
<xsl:variable name="itemURL">
<xsl:value-of select="s:loc"/>
</xsl:variable>
<a href="{$itemURL}">
<xsl:value-of select="s:loc"/>
</a>
</td>
<td>
<xsl:value-of select="concat(substring(s:lastmod,0,11),concat(' ', substring(s:lastmod,12,5)))"/>
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

0 comments on commit e6957ac

Please sign in to comment.