Displaying full content in rss.xml in Hugo
Shubham Kumar

Shubham Kumar @schwiftycold

About: Senior Software Development Engineer (MTS) at GreyOrange.

Location:
India
Joined:
Aug 11, 2023

Displaying full content in rss.xml in Hugo

Publish Date: Mar 2
0 0

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

Comments 0 total

    Add comment