andersonscreekps / andersonscreekps-website

Anderson's Creek Primary School website
0 stars 0 forks source link

Add HTML sitemap #24

Open seamusharris opened 5 years ago

seamusharris commented 5 years ago

Currently linked from footer to /sitemap.hml.

Hugo automatically creates an XML sitemaps but we should also have an HTML one for users to browse. Particularly useful until we implement search.

seamusharris commented 2 years ago

https://github.com/brycewray/hugo_site/blob/main/layouts/sitemap/single.html

{{ define "main" }}

<div class="container-narrower sitemapDiv">
  <h1>Sitemap</h1>
  <div class="post-line"></div>
  <h2>Main pages</h2>
  <ul>
    <li><a href="{{ .Site.BaseURL }}">Home page</a></li>
    <li><a href="{{ .Site.BaseURL }}about/">About me</li>
    <li><a href="{{ .Site.BaseURL }}privacy/">Site&rsquo;s privacy policy</a></li>
    <li><a href="{{ .Site.BaseURL }}contact/">How to contact me</a></li>
  </ul>
  <h2>Posts</h2>
  <ul>
    <li><a href="/posts"><strong>Complete list</strong></a> <em>(first page of paginated list; five posts per page)</em></li>
  {{- range where .Site.Pages.ByPublishDate.Reverse ".Type" "posts" -}}
    {{- if (ne .Title "Posts") -}}
    <li><strong><a href="{{ .Permalink }}">{{ .Title | .Page.RenderString }}</a></strong> &bull; {{ .PublishDate.Format "January 2, 2006" }}<br />
    <em class="description">{{ .Description | .Page.RenderString }}</em></li>
    {{- end -}}
  {{- end -}}
  </ul>
</div>

{{ end }}
seamusharris commented 2 years ago

Discussion at https://www.reddit.com/r/gohugo/comments/tr1rbr/tried_to_ask_a_question_on_hugo_forums_account/