XSL transformation header inclusion in sitemap.XML layout file?

Anyone noticed the problem that comes up when you add a XSL transformation file in the sitemap.xml layout?

<?xml-stylesheet type="text/xsl" href="{{ .Site.BaseURL }}sitemap.xsl"?>

The first 2 chars get encoded in the output. I couldn’t find a solution for this yet.

Output the entire attribute or tag. May need the safeHTML filter, too. Go templates are context aware and don’t like inserting partial tags.

<?xml-stylesheet type="text/xsl" {{ printf "href=\"%ssitemap.xsl\"" .Site.BaseURL | safeHTML }} ?>

We should add an explanation of this to the docs since it comes up often.

I doubt safeHTML will help in this case as the opening angle bracket of the tag gets encoded itself

  • **<?**xml-stylesheet changes to &gt;