Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Images to sitemap.xml #675

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions docs/content/templates/sitemap.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,19 @@ This template respects the version 0.9 of the [Sitemap
Protocol](http://www.sitemaps.org/protocol.html).

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{{ range .Data.Pages }}
{{ range .Data.Pages }}{{ if not .Params.noindex }}
<url>
<loc>{{ .Permalink }}</loc>
<lastmod>{{ safeHtml ( .Date.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ with .Sitemap.ChangeFreq }}
<changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }}
<priority>{{ .Sitemap.Priority }}</priority>{{ end }}
<priority>{{ .Sitemap.Priority }}</priority>{{ end }}{{ range .Params.images }}
<image:image>
<image:loc>.src</image:loc>
{{ with .title }}<image:title><![CDATA[.]]></image:title>{{ end }}
{{ with .caption }}<image:caption><![CDATA[.]]></image:caption>{{ end }}
</image:image>{{ end }}
</url>
{{ end }}
{{ end }}{{ end }}
</urlset>

*Important: Hugo will automatically add the following header line to this file
Expand Down
12 changes: 8 additions & 4 deletions tpl/template_embedded.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,19 @@ func (t *GoHtmlTemplate) EmbedTemplates() {
</rss>`)

t.AddInternalTemplate("_default", "sitemap.xml", `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{{ range .Data.Pages }}
{{ range .Data.Pages }}{{ if not .Params.noindex }}
<url>
<loc>{{ .Permalink }}</loc>
<lastmod>{{ safeHtml ( .Date.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ with .Sitemap.ChangeFreq }}
<changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }}
<priority>{{ .Sitemap.Priority }}</priority>{{ end }}
<priority>{{ .Sitemap.Priority }}</priority>{{ end }}{{ range .Params.images }}
<image:image>
<image:loc>.src</image:loc>
{{ with .title }}<image:title><![CDATA[.]]></image:title>{{ end }}
{{ with .caption }}<image:caption><![CDATA[.]]></image:caption>{{ end }}
</image:image>{{ end }}
</url>
{{ end }}
{{ end }}{{ end }}
</urlset>`)

t.AddInternalTemplate("", "disqus.html", `{{ if .Site.DisqusShortname }}<div id="disqus_thread"></div>
Expand All @@ -93,5 +98,4 @@ func (t *GoHtmlTemplate) EmbedTemplates() {
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>{{end}}`)

}