DEV Community

Shubham Kumar
Shubham Kumar

Posted on • Originally published at blog.shubham.codes on

Displaying full content in rss.xml in Hugo

Create a new file at layouts/_default/rss.xml. You can define your rss.xml as per your liking.

By default rss.xml only displays the summary of your articles. But I want to display the whole content. This helps me in syncing my posts with my dev.to site.

You can find the Hugo’s default rss.xml at Hugo’s Github repo. Let’s copy the contents to our rss.xml file that we just created.

Then change the description to show content instead of summary as follows.

-<description>{{ .Summary | transform.XMLEscape | safeHTML }}</description>
+<description>{{ .Content | transform.XMLEscape | safeHTML }}</description>

Enter fullscreen mode Exit fullscreen mode

Before the changes there were only 504 characters in the characters.

curl localhost:1313/index.xml | grep "description" | head -n 3 | tail -n 1 | wc -c

: 504
Enter fullscreen mode Exit fullscreen mode

After the changes the number of characters increased significantly as the whole blog is being rendered in the description.

curl localhost:1313/index.xml | grep "description" | head -n 3 | tail -n 1 | wc -c

: 14582
Enter fullscreen mode Exit fullscreen mode

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay