mirror of
https://github.com/foo-dogsquared/hugo-theme-contentful.git
synced 2025-02-07 18:19:22 +00:00
157 lines
7.3 KiB
HTML
157 lines
7.3 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en-us"><title>Creating an archive page</title>
|
||
<link rel="stylesheet" href="https://foo-dogsquared.github.io/hugo-theme-contentful/css/main.min.ac4668a81007ca38fcac8e88436ad4fa6a969ee4ce9352f52f795abf04e1624a.css" /><meta name="generator" content="Hugo 0.76.0" />
|
||
<meta charset="utf-8">
|
||
<meta name="author" content="" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||
<meta name="referrer" content="no-referrer" />
|
||
<meta name="description" content="This will add an archive page similar to archive pages like these.
|
||
{{- define "main" -}} <h1>{{ .Title }}</h1> {{ .Content }} <hr> {{- /* Creating a section that lists out regular pages by year */ -}} {{ range $.Site.RegularPages.GroupByPublishDate "2006" }} {{- /* Skip regular pages with an invalid creation date string. */ -}} {{- /* This is convenient if we want to exclude certain posts to be listed by giving no value to `date` in the frontmatter." /><meta name="twitter:card" content="summary"/>
|
||
<meta name="twitter:title" content="Creating an archive page"/>
|
||
<meta name="twitter:description" content="This will add an archive page similar to archive pages like these.
|
||
{{- define "main" -}} <h1>{{ .Title }}</h1> {{ .Content }} <hr> {{- /* Creating a section that lists out regular pages by year */ -}} {{ range $.Site.RegularPages.GroupByPublishDate "2006" }} {{- /* Skip regular pages with an invalid creation date string. */ -}} {{- /* This is convenient if we want to exclude certain posts to be listed by giving no value to `date` in the frontmatter."/>
|
||
<meta property="og:title" content="Creating an archive page" />
|
||
<meta property="og:description" content="This will add an archive page similar to archive pages like these.
|
||
{{- define "main" -}} <h1>{{ .Title }}</h1> {{ .Content }} <hr> {{- /* Creating a section that lists out regular pages by year */ -}} {{ range $.Site.RegularPages.GroupByPublishDate "2006" }} {{- /* Skip regular pages with an invalid creation date string. */ -}} {{- /* This is convenient if we want to exclude certain posts to be listed by giving no value to `date` in the frontmatter." />
|
||
<meta property="og:type" content="article" />
|
||
<meta property="og:url" content="https://foo-dogsquared.github.io/hugo-theme-contentful/recipes/creating-an-archive-page/" />
|
||
<meta property="article:published_time" content="2020-10-20T20:36:55+08:00" />
|
||
<meta property="article:modified_time" content="2020-10-24T15:49:14+08:00" />
|
||
<link rel="canonical" type="text/html" href="https://foo-dogsquared.github.io/hugo-theme-contentful/recipes/creating-an-archive-page/" />
|
||
|
||
<script>
|
||
const theme = window.localStorage.getItem('theme');
|
||
if (theme) {
|
||
document.documentElement.dataset.theme = theme;
|
||
}
|
||
</script>
|
||
<body><nav aria-label="Primary navigation">
|
||
<a class="site__title" href="https://foo-dogsquared.github.io/hugo-theme-contentful/">Contentful</a>
|
||
<div class="site__links">
|
||
|
|
||
<a href="https://foo-dogsquared.github.io/hugo-theme-contentful/about/">About</a> |
|
||
<a href="https://foo-dogsquared.github.io/hugo-theme-contentful/categories/">Categories</a> |
|
||
<a href="https://foo-dogsquared.github.io/hugo-theme-contentful/recipes/">Recipes</a> |
|
||
<a href="https://foo-dogsquared.github.io/hugo-theme-contentful/tags/">Tags</a> |
|
||
|
||
</div>
|
||
<button class="site__theme-btn" aria-label="theme-toggle" onclick="const theme = window.localStorage.getItem('theme') == 'dark' ? 'light' : 'dark'; window.localStorage.setItem('theme', theme); document.documentElement.dataset.theme = theme">
|
||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
||
<path d="M0 12c0 6.627 5.373 12 12 12s12-5.373 12-12-5.373-12-12-12-12 5.373-12 12zm2 0c0-5.514 4.486-10 10-10v20c-5.514 0-10-4.486-10-10z"></path>
|
||
</svg>
|
||
</button>
|
||
</nav>
|
||
|
||
|
||
<article>
|
||
<header>
|
||
<h1>Creating an archive page</h1>
|
||
</header>
|
||
<div class="post__meta">
|
||
|
||
|
||
|
||
<p data-content-publication-date="2020-10-20 20:36:55 +0800 +0800">Created: <time datetime="2020-10-20">2020-10-20</time></p>
|
||
|
||
|
||
<p data-content-modification-date="2020-10-24 15:49:14 +0800 +0800">Updated: <time datetime="2020-10-24">2020-10-24</time></p>
|
||
|
||
|
||
</div>
|
||
<hr>
|
||
|
||
|
||
|
||
<style>
|
||
#TableOfContents:not(:empty)::before {
|
||
content: "Table of contents";
|
||
font-weight: bold;
|
||
}
|
||
</style>
|
||
<nav id="TableOfContents"></nav>
|
||
|
||
|
||
<main>
|
||
<div class="paragraph">
|
||
<p>This will add an archive page similar to archive pages <a href="https://davidtranscend.com/archives/">like</a> <a href="https://lukesmith.xyz/blogindex.html">these</a>.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="highlight"><code class="language-go" data-lang="go">{{- define "main" -}}
|
||
|
||
<h1>{{ .Title }}</h1>
|
||
|
||
{{ .Content }}
|
||
|
||
<hr>
|
||
|
||
{{- /* Creating a section that lists out regular pages by year */ -}}
|
||
{{ range $.Site.RegularPages.GroupByPublishDate "2006" }}
|
||
{{- /* Skip regular pages with an invalid creation date string. */ -}}
|
||
{{- /* This is convenient if we want to exclude certain posts to be listed by giving no value to `date` in the frontmatter. */ -}}
|
||
{{- /* We will also exclude hidden pages. */ -}}
|
||
{{ if ne .Key "0001" }}
|
||
<section data-year="{{ .Key }}">
|
||
<h2 id="{{ .Key }}">{{ .Key }}</h2>
|
||
<ul>
|
||
{{- range where .Pages "Params.hidden" "!=" true -}}
|
||
<li>
|
||
<date>{{ .Date.Format "2006-01-02" }}</date> -
|
||
<a aria-label="{{ .Title }}" href="{{ .Permalink }}">{{ .Title }}</a>
|
||
</li>
|
||
{{- end -}}
|
||
</ul>
|
||
</section>
|
||
{{- end }}
|
||
{{ end }}
|
||
|
||
{{- end -}}</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>We will simply add this as a layout in our customized theme.
|
||
Let’s call it <code>archives</code> so we have to add a file in <code>layouts/_default/archives.html</code> then set a page of our project with the <code>layout</code> key in the frontmatter.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>We want the archives page to be accessed at <code>$.Site.BaseURL/archives</code> so we’ll simply create <code>archives.adoc</code> (<a href="https://gohugo.io/content-management/formats/#list-of-content-formats">any valid content files with certain file extensions can do</a>, I’m using <a href="https://asciidoctor.org/">Asciidoctor</a>) with the following example content.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="highlight"><code class="language-asciidoctor" data-lang="asciidoctor">---
|
||
title: "Archives"
|
||
layout: "archive"
|
||
---
|
||
|
||
= Archives
|
||
|
||
This is the archives of the century.</code></pre>
|
||
</div>
|
||
</div>
|
||
|
||
</main>
|
||
</article>
|
||
|
||
<hr>
|
||
<footer>
|
||
|
||
<p><a href="https://foo-dogsquared.github.io/hugo-theme-contentful/">Back to home</a></p>
|
||
</footer>
|
||
|
||
|
||
|
||
<p>Available in other languages:
|
||
<span class="site__languages">|
|
||
|
||
<a href="/hugo-theme-contentful/en">English</a> |
|
||
|
||
<a href="/hugo-theme-contentful/tl">Tagalog</a> |
|
||
|
||
</span>
|
||
</p>
|
||
|
||
|
||
|
||
<p>© 2021 Contentful</p>
|
||
</body>
|
||
</html>
|