XSL Stylesheet for RSS Feeds?

Hello!

One can style an RSS feed using an xsl file. For a very pretty example of this, see: Rach Smith's digital garden

To do so, you need an RSS formatted index.xml and a style.xsl. I would like add xsl stylesheets to my the RSS feeds of my Hugo site. My problem is this: I can modify the default rss.xml template to reference the xsl stylesheet, but I can’t seem to figure out a way to get a copy of style.xsl in every directory that needs one.

To be a bit more concrete, here is what I’ve done so far: I pulled down the default rss.xml template from here:

I’ve put it in the follow spot:

/themes/accessible-minimalism/layouts/_default/rss.xml
All that works fine, and I can see the RSS feeds being generated for all my sections.

And I’ve modified rss.xm so that it also calls for the style.xsl:

{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
{{- printf "<?xml-stylesheet href=\"style.xsl\" type=\"text/xsl\"?>" | safeHTML }}

The issue I’m having is very silly: How do I get the style.xsl to be place everywhere the index.xml file (RSS feed) is placed?

Many thanks!

Instead of placing of copy of the XSL file adjacent to each index.xml file, just drop it in the static directory and change this:

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

to this:

{{- printf "<?xml-stylesheet href=%q type=\"text/xsl\"?>" ("style.xsl" | relLangURL) | safeHTML }}
1 Like

Oh my goodness! That’s so much simpler than what I had imagined. Of course, it works like a charm. Thank you so much.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.