disableKinds and RSSLink not playing together

Hi!

I use a vanilla hugo theme for all web projects.

My config.toml says

disableKinds = ["RSS"]

(which may be deleted—depending on the project).

The header.html contains these lines:

{{ if .RSSLink }}
<link href="{{ .RSSLink }}" rel="alternate" type="application/rss+xml" />
{{ end }}

.RSSLink is true even if RSS is disabled, that is the link to the xml file is printed although no index.xml is generated—as planned.

Is this the intended behaviour, and is there a way to check whether the disableKinds array contains RSS?

Thank you!

I have been looking for a way to make this work also…

my logic would suggest your standard code…

{{ if .RSSLink }}
<link href="{{ .RSSLink }}" rel="alternate" type="application/rss+xml" />
{{ end }}

is at fault as it is only looking for the link name which is set by default in config to index.xml - so therefore… there is a link name set in config and your <link… will be generated and throw a 404 as you have RSS turned off in disableKinds

but, @rdwatters .RSSLink is still listed as the standard method for access in docs - template/rss

I think you are on the right track looking to the newer disableKinds array…

I have tried…

{{ if not (in .Site.DisableKinds "RSS") }}
<link rel="alternate" href="{{ .RSSlink }}" type="application/rss+xml" title="{{ .Site.Title }}">
{{ end }}

also tried…

{{ if not (isset .Site.DisableKinds “RSS”) }}

but my knowledge/experience may be lacking as it throws errors either way with …

…can’t evaluate field DisableKinds

Any help in the right direction would be appreciated

I noticed the same behaviour today. It might not be a bug (as in, programming error), but we can probably implement this better. Because as you already point out, if disableKinds disables the RSS feeds, it would make more sense if .RSSLink returns false or null so that the conditional if statement doesn’t execute.

That way the template code that the documentation suggests to include the RSS feed actually points to a RSS feed (and doesn’t give 404 errors).

I also couldn’t get access to the current disableKinds setting as a work around.

@Jura I’m having the same problem. Did you find a workaround?

Maybe we should fill an issue. IMO .RSSLink should be false/empty when RSS is disabled. If this isn’t an option (maybe there is a use case I’m not seeing), at least there should be a way to check if RSS is enabled.

No I didn’t. I agree that .RSSLink should be empty when there’s no RSS feed. At least to me that seems more intuitive.

RSSLink will be deprecated and removed at some point, so we’re not spending time fixing that (and I’m not even sure it behaves wrongly).

What you probably want to do is to use the output formats API:

Thank you very much for your response. Using the the outputs API makes much more sense.

I tried

{{ range .AlternativeOutputFormats }}
<link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}">
{{ end }}

and found that the outputs defaults some pages to HTML and RSS even when RSS is disabled with

disableKinds = ["RSS"]

Also the generated <link> doesn’t match what the documentation suggests:

  1. The type attribute generated this way is “application/rss” while the documentation recommends “application/rss+xml”.
  2. the <link> with rel=“feed” is not generated

What do you think about this?

I think the documentation should be fixed. Pull requests are welcome.

Yes, of course. But besides fixing the documentation:

  1. Should disableKinds = ["RSS"] disable the default RSS outputs?
  2. Should the RSS mime type be "application/rss+xml" instead of "application/rss"?
  3. Should the additional <link href="[link]" rel="feed" type="application/rss+xml" title="[title]" /> be generated? (thanks @it-gro)

https://www.w3.org/TR/html5/links.html#allowed-keywords-and-their-meanings

rel=“feed” is not valid …

  1. RSS is not a kind (or it is, but that is for internal use and will be removed soon). To disable RSS you need to define output formats…
  2. The mime type should be the output of the RSS output format, i.e. “application/rss”
  3. What he said.

I’ll definitely try to fix the docs where I can, there’s a lot of confusing stuff out there :stuck_out_tongue:

I’m not sure what you meant with this. Hugo is outputting <link rel="alternate" type="application/rss" href="[url]"> but the correct type seems to be "application/rss+xml" (even though the applications handle lots of non standard types for rss). Please let me know if I am missing something here.


Summing up for other readers (specifically @Jura):

  1. RSS “kind” will be removed (so disableKinds = ["RSS"] alone to disable RSS won’t work anymore).

  2. The correct way of disabling RSS is by overriding the default RSS pages output.

  3. .RSSLink will be deprecated and removed.

  4. The correct way of declaring the rss links (and other alternate outputs) is:

     {{ range .AlternativeOutputFormats }}
     <link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}">
     {{ end }}
    

Thanks everyone for your input.

I meant exactly what I said. I’m not sure how it could be clearer.

Sorry if this is obvious, I’m not a web developer. You said that the mime type should be "application/rss" but the correct one seems to be "application/rss+xml" (other sources: https://developer.mozilla.org/en-US/docs/Archive/RSS/Getting_Started/Syndicating, https://en.wikipedia.org/wiki/RSS, etc.). So naturally I’m not sure if you are referring to something I don’t know, or if you are not correct about the mime type. That’s why I din’t find your statement clear.

My two cents :wink:

The thing about mimetypes is, that they are recommendations, not the law. They basically tell the “consuming party” what can be expected as the content and formatting of the file they are receiving so they can display them right. “consuming party” being browsers and rss readers.

application/rss+xml might be the “official” solution the RSS board expects.
application/rss does not really exist out there

but

application/xml is the most compatible solution. Because RSS as such is an XML format and the resulting XML has information in the starting tag what specifications to use for special tags:

<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"> - the xmlns:atom would give the browser all the hints, what the meaning of atom-tags are, like: <atom:link href="some link" rel="self" type="application/rss+xml"/>. Even if this information would not be available the consumer could parse the tag and use it as textual information.

https://validator.w3.org/feed/docs/warning/UnexpectedContentType.html < they propose to use just the application/xml tag.

I think the main issue in implementing this might be, that Hugo seems to push through the “Hugo mimetype” as “application/HugoMimetype” where it should have some kind of mapping what mimetype-extension to print.

But this is just IMHO. I would be solving the original issue up top with a own parameter in my config that gets checked.

I know this is a feature of software that isn’t in version 1.0 yet, but can you share which other Hugo features are scheduled to be removed or have their meaning change?

That’s good to know for the community so we don’t have people blog about stuff that gets removed. Or use features in their theme that error seen, adding to more confusion.