Skip to content
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

Empty RSS href in posts #403

Closed
whatacold opened this issue Jul 15, 2021 · 10 comments
Closed

Empty RSS href in posts #403

whatacold opened this issue Jul 15, 2021 · 10 comments

Comments

@whatacold
Copy link
Contributor

whatacold commented Jul 15, 2021

The RSS href in posts are empty with html:

<a href="" title="RSS">
              <span class="fa-stack fa-lg">
                <i class="fas fa-circle fa-stack-2x"></i>
                <i class="fas fa-rss fa-stack-1x fa-inverse"></i>
              </span>
            </a>

For comparison,

But it's okay on the homepage and section pages.

@RoneoOrg
Copy link
Collaborator

Hi @whatacold,

I'm not facing this issue, is your code available somewhere online?
You can compare your code to my repo, the result can be seen on roneo.org

@whatacold
Copy link
Contributor Author

Still not working after trying:

  1. using your beautifulhugo theme commit https://github.com/RoneoOrg/beautifulhugo/tree/74363aabe231e5d7d0a14f780ec8fc077f822f2c
  2. using the latest hugo version hugo v0.87.0-B0C541E4+extended

It looks like {{ with .OutputFormats.Get "RSS" }} is false for blog post, but I can't figure out why:(

@whatacold
Copy link
Contributor Author

I don't get it, maybe I simply don't show it on post pages, by hacking that part of layouts/partials/footer.html to as follows:

          {{ if .Site.Params.rss }}
          {{ with .OutputFormats.Get "RSS" }}
          <li>
              <a href="{{ .RelPermalink }}" title="RSS">
                  <span class="fa-stack fa-lg">
                      <i class="fas fa-circle fa-stack-2x"></i>
                      <i class="fas fa-rss fa-stack-1x fa-inverse"></i>
                  </span>
              </a>
          </li>
          {{ end }}
          {{ end }}

@RoneoOrg
Copy link
Collaborator

RoneoOrg commented Aug 6, 2021

Give a try to

          {{ if .Site.Params.rss }}
          <li>
            <a href="{{ with .OutputFormats.Get "RSS" }}{{ .RelPermalink }}{{ end }}" title="RSS">
              <span class="fa-stack fa-lg">
                <i class="fas fa-circle fa-stack-2x"></i>
                <i class="fas fa-rss fa-stack-1x fa-inverse"></i>
              </span>
            </a>
          </li>
          {{ end }}

Reference: https://github.com/RoneoOrg/WonderfulHugo/blob/74363aabe231e5d7d0a14f780ec8fc077f822f2c/layouts/partials/footer.html#L21

See also https://framagit.org/roneo/roneo.frama.io/-/blob/master/layouts/_default/rss.xml
and #330

@whatacold
Copy link
Contributor Author

Woops, this is a duplicate of #330 .

Give a try to
Seems like this snippet is what it was before I worked-around it.

My understanding is that hugo doesn't assign {{ with .OutputFormats.Get "RSS" }} internally, so there is nothing beautifulhugo can do here. But I don't have the energy to investigate it further on the hugo code base.

BTW, which hugo version do you use?

@RoneoOrg
Copy link
Collaborator

BTW, which hugo version do you use?

I'm using hugo_extended:0.80.0 on roneo.org.
Hint: you can check which version is used by a project in his gitlab-ci.yml
For example: https://framagit.org/roneo/roneo.frama.io/-/blob/master/.gitlab-ci.yml#L1

@whatacold
Copy link
Contributor Author

Thanks for the pointer, I also use this version.

I'm going to build your sites and see how it works, if I have the time.

@RoneoOrg
Copy link
Collaborator

Hi @whatacold, could you please close this issue and re-open if you have time to make a test and face a problem?
(let's try to keep this bug tracker not-too-scary 😅 !)

@whatacold
Copy link
Contributor Author

OK, the workaround I took was not to show RSS on posts.

@GSGBen
Copy link

GSGBen commented Dec 31, 2021

I've fixed this. The issue is that the page type doesn't have an RSS feed output, and it wouldn't make sense to - it'd only show updates for that page. This also brings up that the RSS button in different sections shows a specific RSS link for that section, that only has posts for that section.

A clearer model is to simply use the same single site (home page) RSS link for all, assuming you show posts on your front page.

In <beautifulhugo>/layouts/partials/footer.html, change

<a href="{{ with .OutputFormats.Get "RSS" }}{{ .RelPermalink }}{{ end }}" title="RSS">

to

<a href="{{ printf "%s%s" site.BaseURL "index.xml"}}" title="RSS">

If you want a fixed version of the previous functionality, where it uses the page's (section's) RSS feed if it exists, otherwise falls back to the main site one, change it to:

<a href="
{{ if (.OutputFormats.Get "RSS") }}
  {{ (.OutputFormats.Get "RSS").RelPermalink }}
{{ else }}
  {{ printf "%s%s" site.BaseURL "index.xml"}}
{{ end }}
" title="RSS">

whatacold added a commit to whatacold/beautifulhugo that referenced this issue Nov 14, 2023
BarthPaleologue added a commit to BarthPaleologue/beautifulhugo that referenced this issue Feb 13, 2024
fix halogenica#403: Exclude the rss link in the post pages as it's empty.
sunpech pushed a commit to sunpech/beautifulhugo that referenced this issue Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants