# XSL Stylesheet for RSS Feeds?

**URL:** <https://discourse.gohugo.io/t/xsl-stylesheet-for-rss-feeds/53701>\
**Category:** support\
**Created:** [February 26, 2025, 9:34pm UTC](https://discourse.gohugo.io/t/xsl-stylesheet-for-rss-feeds/53701 "2025-02-26T21:34:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pgadey](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pgadey/32/23984_2.png) [@pgadey](https://discourse.gohugo.io/u/pgadey)\
**Post date:** [February 26, 2025, 9:34pm UTC](https://discourse.gohugo.io/t/xsl-stylesheet-for-rss-feeds/53701/1 "2025-02-26T21:34:10Z")

</div>

Hello!

One can style an RSS feed using an xsl file. For a very pretty example of this, see: [Rach Smith's digital garden](https://rachsmith.com/feed.xml)

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:

> <https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_default/rss.xml>

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`:

```auto
{{- 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!

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [February 26, 2025, 10:38pm UTC](https://discourse.gohugo.io/t/xsl-stylesheet-for-rss-feeds/53701/2 "2025-02-26T22:38:56Z")

</div>

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:

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

```

to this:

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

```

---

<div class="post-metadata">

**Author:** ![pgadey](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pgadey/32/23984_2.png) [@pgadey](https://discourse.gohugo.io/u/pgadey)\
**Post date:** [February 27, 2025, 3:48pm UTC](https://discourse.gohugo.io/t/xsl-stylesheet-for-rss-feeds/53701/3 "2025-02-27T15:48:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [March 1, 2025, 3:48pm UTC](https://discourse.gohugo.io/t/xsl-stylesheet-for-rss-feeds/53701/4 "2025-03-01T15:48:34Z")

</div>

Closed on March 1, 2025, 3:48pm UTC

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