Skip to content

Add support for RSS Feed#258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 26, 2024
Merged

Add support for RSS Feed #258

merged 6 commits into from
Dec 26, 2024

Conversation

stumbo
Copy link
Member

Update the hugo.yaml configuration file to support RSS Feeds:

  • Remove RSS from the disabledKinds. This enables RSS generation within the site
  • Add outputs setting default output types for sections and pages as html. We enable RSS on only the project/status page by updating it's front matter
  • Set enableGitInfo to true. This provides information on commit dates which we will use for populating published dates of pages

Update the params.yaml file adding in the RSS Feed information. We add it to the collection of social media options that are published on the left hand side of the footer. Of particular note is the format of the rss url. There is no leading slash in the address to the index.xml file. This is purposeful. We need to generate an appropriate url in the footer and we don't want to hard code the site name (Interlisp.org) so that when we build it locally or on the staging site the address is correct. When we create the url the hugo mechanism for calculating the name uses the lack of a leading slash to signal adding in the complete path offset of the host site - for our production site that will be Interlisp.org for our staging site there it currently is stumbo.github.io/InterlispDraft.github.io. If we include the leading slash, Hugo will remove the InterlispDraft.github.io from the address, which leads to a 404 if you attempt to follow the link.

Update content/en/project/status/_index.md specifying the output types as both html and RSS.

Add layouts/_defaults/rss.xml. We add a custom rss.xml that will add both sections and pages to the rss feed. This means subsections will be included, and more specifically, the _index.md page, which is treated as a section page, will be included in the rss feed. Given several sections within our website have all their material included on the _index.md page this ensures changes are included in the feed.

Add layouts/partials/footer/links.html. We customize the footers to include the RSS feed, and when we insert the url, calculate the correct url. The href="{{ absURL .url }}" is the magic here. It creates an absolute url from the baseURL and the url provided for the RSS feed in params.yaml.

Add layouts/partials/page-meta-lastmod.html. When we set enableGitInfo to true in hugo.yaml, we by default get the last modified date and commit message appended to the bottom of each page. We don't want that, so these edits comment out the capability.

navbar.html by defalut puts the title on every page. This update modifies it to not put the title on the home page. The title already is a central part of the text within the page and having it on the home page is redundant. Defining the title in the config comes in useful for other Hugo templates that want to use the title of the website.
RSS Feed generates feed containing all subpages from these sections.
Update rssFeed url value to project/status page Add frontmatter and enable git info These changes allow us to get the last modified date for pages. Update page-meta-lastmod file to not show git commit info
@stumbostumbo self-assigned this Dec 26, 2024
@stumbo
Copy link
MemberAuthor

These changes are currently live on the staging site at:  https://stumbo.github.io/InterlispDraft.github.io/

Copy link
Contributor

@pamorosopamoroso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good. A new section on the page triggers a new RSS item. It's already useful as is but it would be great to have items sent out also when sections are edited.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, Hugo makes you do to a lot of work to produce an RSS feed for a given page.
Two questions:

  • If we want additional RSS feeds, will we need to copy-paste this code in all of them? Or can we place it in a central spot and include or import it where needed?
  • Can we change the name of the feed file from "index.xml" to just plain "rss" or "rss.xml"? For example, the feed URL is now "../project/status/index.xml". If Hugo permits it, could it instead be "../project/status/rss" or "../project/status/rss.xml"?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the feed's title and description are kind of phrased oddly.

Title:
News and Status Reports on The Medley Interlisp Project

Description:
Recent content in News and Status Reports on The Medley Interlisp Project

Looking at the Hugo configuration, I couldn't figure out a way to override these. They're not directly derived from the page title, which is News and Status Reports | The Medley Interlisp Project.

I'd love it if the RSS feed's title and description were both Updates from the Medley Interlisp Project, or maybe Medley Interlisp Project: Latest News, or something like that.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding additional RSS Feeds is straight forward.  It only requires an addition to the front matter of the page where we want to add it.  See content/en/project/status/_index.md  the following lines turn rss on for that page:

outputs: - html - rss

Any page whose front matter has those lines, will generate an rss feed.

One thing we should then consider, do we want the feed in the footer to reflect the root of our site?  Or, do we want it to remain the /project/status/rss.xml feed?  And, if that is the case, how do we make users aware of other potential locations where feeds are available? 

Making the footer feed vary by page would be confusing to users, that link should be stable.  Adding another RSS Feed link on pages that supports feed might also be confusing.  Identical icons in different places on the page that have different behaviors, one whose behavior varies by page.

The answer to your second question is yes, I'll push an update to this PR that supports renaming the feed from index.xml to rss.xml.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Page Title and Description are generated in layouts/_default/rss.xml

<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title><link>{{ .Permalink }}</link><description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>

I can modify the phrasing to be more in line with your ask.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding additional RSS Feeds is straight forward. It only requires an addition to the front matter of the page where we want to add it. See content/en/project/status/_index.md the following lines turn rss on for that page:

outputs: - html - rss

Any page whose front matter has those lines, will generate an rss feed.

One thing we should then consider, do we want the feed in the footer to reflect the root of our site? Or, do we want it to remain the /project/status/rss.xml feed? And, if that is the case, how do we make users aware of other potential locations where feeds are available?

Making the footer feed vary by page would be confusing to users, that link should be stable. Adding another RSS Feed link on pages that supports feed might also be confusing. Identical icons in different places on the page that have different behaviors, one whose behavior varies by page.

I agree. We need to get in the practice of updating the project/status page whenever we make a substantive change to the site, so having project/statusgenerate the site-wide RSS feed would be fine, at least for now.

If we want individual per-page feeds in the future, we can figure out a place for those icons on the specific pages.

Let's start out with a single feed, visible site-wide, that contains updates to the project/status page.

The answer to your second question is yes, I'll push an update to this PR that supports renaming the feed from index.xml to rss.xml.

Title and Description are set to Updates from the Medley Interlisp Project.
@stumbostumbo merged commit 44f0ed8 into mainDec 26, 2024
@stumbostumbo deleted the rssFeed branch December 26, 2024 22:32
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants
@stumbo@hjellinek@pamoroso
close