imfing / hextra

🔯 Modern, batteries-included Hugo theme for creating beautiful doc, blog and static websites
https://imfing.github.io/hextra/
MIT License
716 stars 171 forks source link

Generate full content on RSS instead of only summary #66

Closed vinay-keshava closed 1 year ago

vinay-keshava commented 1 year ago

I've used the template repository to create a hugo site and the index.xml doesn't generate full contents it only generates summary Help or insight needed on this !

Enable Full Text RSS feed

this is an example site which generates full content which enhances readability in RSS https://blog.sahilister.in/index.xml

imfing commented 1 year ago

it's generating the full content in the RSS feed, for example, the blog section https://imfing.github.io/hextra/blog/index.xml

and RSS is enabled here in the docs site for sections: https://github.com/imfing/hextra/blob/c799160e86279ade57033721c9b6698451baf65a/exampleSite/hugo.yaml#L10-L13

vinay-keshava commented 1 year ago

image i've added the above config to hugo.yaml still the whole content is not shown on RSS

imfing commented 1 year ago

try localhost:1313/blog/index.xml it should contain the full content RSS feed

vinay-keshava commented 1 year ago

i tried it for blog/ and docs/ too

imfing commented 1 year ago

I'll look into this. It would be nice if you could share an example repository for reproducing the issue.

hugo-sid commented 1 year ago

AFAIK, unless a custom RSS template is specified, Hugo includes only a summary of an article (or blog post) in RSS feed. This is due to <description>{{ .Summary | html }}</description> in the default RSS template.

To include full post content in feed, a custom RSS template should be defined with .Content (instead of .Summary).

INMHO, it would be better to introduce a switch that allows controlling this feature (displaying full posts in the RSS feed) through a configuration parameter, with 'summary' as the default setting. Here is an example where this is implemented: https://github.com/hugo-sid/hugo-blog-awesome/pull/113.

imfing commented 1 year ago

AFAIK, unless a custom RSS template is used, Hugo includes only a summary of the article in RSS feed. This is due to the <description>{{ .Summary | html }}</description> in the default RSS template.

To include the full post content in feed, a custom RSS template should be defined with .Content (instead of .Summary).

INMHO, it's better to provide a switch to control this feature (full post in RSS feed) via one of the config parameters. Here is an example where this is implemented: https://github.com/hugo-sid/hugo-blog-awesome/pull/113.

@hugo-sid Thanks for the info.

FYI, I have implemented full content RSS in layouts/section/section.rss.xml for sections like blog, but the contents are not placed in the description tags.

If the OP wants descriptions tag, then the only way is to override the RSS template.

hugo-sid commented 1 year ago

Thanks for the info @imfing.

FYI, I have implemented full content RSS in layouts/section/section.rss.xml for sections like blog, but the contents are not placed in the description tags.

Yes, I saw that just now.

If the OP wants descriptions tag, then the only way is to override the RSS template.

Agree.

BTW, this is what I see at https://imfing.github.io/hextra/blog/index.xml :

image

imfing commented 1 year ago

BTW, this is what I see at https://imfing.github.io/hextra/blog/index.xml

@hugo-sid I was aware of this, basically it lacks the xmlns:content="http://purl.org/rss/1.0/modules/content/" attribute on <rss>

I will create a PR to fix a couple of things for the RSS feed.

imfing commented 1 year ago

@hugo-sid I've created a PR #75 the RSS feed xml is parsed correctly by the browser now: https://deploy-preview-75--hugo-hextra.netlify.app/blog/index.xml

hugo-sid commented 1 year ago

@hugo-sid I've created a PR #75 the RSS feed xml is parsed correctly by the browser now: https://deploy-preview-75--hugo-hextra.netlify.app/blog/index.xml

Great!

vinay-keshava commented 1 year ago

Great https://github.com/vinay-keshava/blog this is the link to my site,i've also updated the hugo.yaml to generate rss but gives a 404 for both blog Have used the template repository

imfing commented 1 year ago

Please rename contents/posts to contents/blog

otherwise access it using /posts

vinay-keshava commented 1 year ago

Please rename contents/posts to contents/blog

otherwise access it using /posts

image

i have renamed it to blog/ now it says XML Parsing Error: prefix not bound to a namespace Location: http://localhost:1313/blog/index.xml Line Number 17, Column 7:

for both blog/index.xml and docs/index.xml

imfing commented 1 year ago

Can you also update the theme version please?

vinay-keshava commented 1 year ago

Can you also update the theme version please?

in go.mod

module github.com/imfing/hextra-starter-template

go 1.21

require github.com/imfing/hextra v0.5.0 // indirect
vinay-keshava commented 1 year ago

Can you also update the theme version please?

in go.mod


![image](https://github.com/imfing/hextra/assets/74909320/4bb68352-442e-4fc7-9d04-bea225da2902)

after updating the version the theme version docs/ directory generates rss but not blog/(have pushed the changes to the repo)

module github.com/imfing/hextra-starter-template

go 1.21

require github.com/imfing/hextra v0.5.0 // indirect

imfing commented 1 year ago

You may need to create a _index.md file under the blog section.

Please follow the exampleSite provided in this repository

vinay-keshava commented 1 year ago

You may need to create a _index.md file under the blog section.

Please follow the exampleSite provided in this repository

Its still the same even after adding the _index.md i've followed the exampleSite in this repository.

imfing commented 1 year ago

@vinay-keshava I took a quick look of your repo, there are two issues:

  1. Please remove the type: post from your blog posts files, it's gonna mess up how Hugo looks up for template. I think this is the main reason why the RSS feed not showing the full content. https://github.com/vinay-keshava/blog/blob/6045e00579d0fad578ac217a40e87ff17eea044b/content/blog/contributing-to-debian.md?plain=1#L6

after remove the frontmatter, the RSS content shows up: image

  1. This reference of the next page won't work: https://github.com/vinay-keshava/blog/blob/6045e00579d0fad578ac217a40e87ff17eea044b/content/docs/_index.md?plain=1#L3 it prevents the site from compiling. You need to replace it with next: blog/interception-vimproved
vinay-keshava commented 1 year ago

@imfing thanks a lot for helping,i was a noob at hugo. Fixed these issues and it started working

imfing commented 1 year ago

@vinay-keshava no problem, this might also help people who may encounter the same problem in the future 😃