halogenica / beautifulhugo

Theme for the Hugo static website generator
Other
1.14k stars 602 forks source link

Empty RSS href in posts #403

Closed whatacold closed 3 years ago

whatacold commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 https://github.com/halogenica/beautifulhugo/issues/330

whatacold commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

GSGBen commented 2 years ago

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">