mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-14 08:18:30 +00:00
update rss linking docs
This commit is contained in:
1 parent
7ef44d262f
commit
20e8a21f65
1 file changed
+10
-12
+10
-12
@@ -114,26 +114,24 @@ Hugo will automatically add the following header line to this file on render. Pl
|
|||||||
|
|
||||||
## Reference your RSS Feed in `<head>`
|
## Reference your RSS Feed in `<head>`
|
||||||
|
|
||||||
In your `header.html` template, you can specify your RSS feed in your `<head></head>` tag like this:
|
In your `header.html` template, you can specify your RSS feed in your `<head></head>` tag using Hugo's [Output Formats][Output Formats] like this:
|
||||||
|
|
||||||
```
|
```
|
||||||
{{ if .RSSLink }}
|
{{ range .AlternativeOutputFormats -}}
|
||||||
<link href="{{ .RSSLink }}" rel="alternate" type="application/rss+xml" title="{{ .Site.Title }}" />
|
<link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}" title="{{ $.Site.Title }}">
|
||||||
<link href="{{ .RSSLink }}" rel="feed" type="application/rss+xml" title="{{ .Site.Title }}" />
|
{{ end -}}
|
||||||
{{ end }}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
...with the auto-discovery link specified by the line with `rel="alternate"`.
|
If you only want the RSS link, you can query the formats:
|
||||||
|
|
||||||
The `.RSSLink` will render the appropriate RSS feed URL for the section, whether it's everything, posts in a section, or a taxonomy.
|
|
||||||
|
|
||||||
If you reference your RSS link, be sure to specify the MIME type with `type="application/rss+xml"`.
|
|
||||||
|
|
||||||
```
|
```
|
||||||
<a href="{{ .URL }}" type="application/rss+xml" target="_blank">{{ .SomeText }}</a>
|
{{ with .OutputFormats.Get "rss" -}}
|
||||||
|
<link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}" title="{{ $.Site.Title }}">
|
||||||
|
{{ end -}
|
||||||
```
|
```
|
||||||
|
|
||||||
[config]: /getting-started/configuration/
|
[config]: /getting-started/configuration/
|
||||||
[embedded]: #the-embedded-rss-xml
|
[embedded]: #the-embedded-rss-xml
|
||||||
[RSS 2.0]: http://cyber.law.harvard.edu/rss/rss.html "RSS 2.0 Specification"
|
[RSS 2.0]: http://cyber.law.harvard.edu/rss/rss.html "RSS 2.0 Specification"
|
||||||
[section]: /content-management/sections/
|
[section]: /content-management/sections/
|
||||||
|
[Output Formats]: /templates/output-formats/#link-to-output-formats
|
||||||
Reference in new issue
Block a user