Hugo: AlternativeOutputFormats generates RSS links when disableKinds=["RSS"] is set

Created on 8 Jun 2018  路  9Comments  路  Source: gohugoio/hugo

I've set disableKinds = [ "taxonomy", "taxonomyTerm", "RSS", "sitemap" ]

I followed the instructions in https://github.com/gohugoio/hugo/issues/4427#issuecomment-366760534 and used

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

in my template. I'd have expected .AlternativeOutputFormats to be empty, but the following RSS link was still generated:

<link rel="alternate" type="application/rss" href="http://localhost:1313/index.xml">

Is this a bug or do I have to set something else to avoid generating RSS links?

I'm using Hugo 0.41 on Mac OS X

Bug

Most helpful comment

The behavior is still present in Hugo 0.55, tested both on macOS and Linux, so it's not platform-dependent.

But there is a new behavior - the deprecated {{ if .RSSLink }} syntax now also generates an RSS link when RSS is disables via disableKinds.

I've experimented some more and found the following patten: disableKinds is independent from the outputs settings. disableKinds suppresses the generation of the files, but does not affect the generated outputs, so RSS is still part of .AlternativeOutputFormats. If I set [outputs] to home=["HTML"], neither the RSS link nor the RSS file are generated. I think the opposite should also be true: when AlternativeOutputFormats contains RSS, the .AlternativeOutputFormats variable should not contain RSS, even if set explicitly in [outputs]

All 9 comments

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

I can still reproduce this bug in Hugo 0.49 on Mac OS X. The only change I have now is a weirdly escaped type attribute:

<link rel="alternate" type="application/rss&#43;xml" href="http://lebenplusplus.de/index.xml">

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

The bug is still present in Hug 0.54.0 on Mac OS X.

The behavior is still present in Hugo 0.55, tested both on macOS and Linux, so it's not platform-dependent.

But there is a new behavior - the deprecated {{ if .RSSLink }} syntax now also generates an RSS link when RSS is disables via disableKinds.

I've experimented some more and found the following patten: disableKinds is independent from the outputs settings. disableKinds suppresses the generation of the files, but does not affect the generated outputs, so RSS is still part of .AlternativeOutputFormats. If I set [outputs] to home=["HTML"], neither the RSS link nor the RSS file are generated. I think the opposite should also be true: when AlternativeOutputFormats contains RSS, the .AlternativeOutputFormats variable should not contain RSS, even if set explicitly in [outputs]

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

The issue still persists with Hugo 0.57:

config.toml contains

disableKinds = [ "taxonomy", "taxonomyTerm", "RSS", "sitemap" ]

head.html contains
`` {{ with .OutputFormats.Get "rss" -}} {{ printf` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end -}}
````

Expected result: Link is not printed

Actual result: Link is printed.

This issue still persists with Hugo 0.62.

Is there a "clean" / suggested way of handling this?

I will fix this in #6738 -- but you should really look into how to configure what output formats to produce.

Was this page helpful?
0 / 5 - 0 ratings