Reading time: 3 minutes
Hugo generatorius ir RSS 2.0
Kaip naudojantis Hugo statinių WEB puslapių generatoriumi sukurti tinkamą RSS sitemap.xml failą? Gali nebeieškoti, nes čia pateiksu trumpą ir aiškų sprendimą.
Visų pirma:
Patikrink ar tavo toml.config konfigūracijos failas atitinka manąjį:
baseURL = "https://nerdy.artefaktas.eu/"
languageCode = "en-us"
title = "Altius Day"
theme = "ananke"
DefaultContentLanguage = "en"
SectionPagesMenu = "main"
Paginate = 3
googleAnalytics = ""
enableRobotsTXT = true
enableEmoji = true
disableKinds = ["taxonomy", "taxonomyTerm"]
[author]
name = "Nerdy Altius"
email = "admin@altiusday.lt"
[params]
favicon = ""
site_logo = ""
description = "AltiusDay tracker"
facebook = "https://www.facebook.com/artefaktas.eu"
twitter = "https://twitter.com/artefaktas"
instagram = "https://www.instagram.com/_artefaktas_"
youtube = ""
github = ""
gitlab = ""
linkedin = ""
mastodon = ""
slack = ""
stackoverflow = ""
rss = "https://nerdy.artefaktas.eu/sitemap.xml"
# choose a background color from any on this page: http://tachyons.io/docs/themes/skins/ and preface it with "bg-"
background_color_class = "bg-dark-gray"
featured_image = ""
recent_posts_number = 12
post_navigation = true
[taxonomies]
tag = "tags"
Susikurk rss.xml failą savo temos direktorijoje
O jei tiksliau, tai \themes\ananke\layouts\ _default naudojantis savo mėgstamiausiu kodo redaktoriumi tereikia sukurti naują failą, suteikti jam rss vardą ir suteikti plėtinį. Tai ypač lengva. Sekantis žingsnis, įdėti į šį failą reikiamą kodą.
Kopijuok ir įklijuok:
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
<link>{{ .Permalink }}</link>
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
<language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
{{ with .OutputFormats.Get "RSS" }}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{ end }}
{{ range .Pages }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
<guid>{{ .Permalink }}</guid>
<description>{{- .Content | html -}}</description>
</item>
{{ end }}
</channel>
</rss>
Išsaugok failą.
Generavimas
Puslapių bei RSS srauto pergeneravimui node.js cmd suvesk:
hugo arba hugo server komandą
Po sėkmingo pergeneravimo pasikeis ir sitemap.xml failas. Dabar jį bus galima naudoti kartu su Feedburner ir suteikti galimybę lankytojams prenumeruotis RSS srauto pranešimus.
Visa pateikiama informacija - asmeninė autoriaus nuomonė. Kilus naiškumams rekomenduojama susisiekti elektroniniu paštu: admin@artefaktas.eu
Artefaktas.eu is licensed under CC BY-NC-ND 4.0