hugo-theme-contentful/recipes/creating-an-archive-page/index.html

146 lines
7.3 KiB
HTML
Raw Normal View History

<!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/index.min.11618edd7e3b000c8d9629ad7f78c9229d907cb12f420c0242dfb9185eb5ff8e.css" /><meta name="generator" content="Hugo 0.98.0" />
<meta charset="utf-8">
<meta name="author" content="John Doe" />
<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 &#34;main&#34; -}} &lt;h1&gt;{{ .Title }}&lt;/h1&gt; {{ .Content }} &lt;hr&gt; {{- /* Creating a section that lists out regular pages by year */ -}} {{ range $.Site.RegularPages.GroupByPublishDate &#34;2006&#34; }} {{- /* 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 &#34;main&#34; -}} &lt;h1&gt;{{ .Title }}&lt;/h1&gt; {{ .Content }} &lt;hr&gt; {{- /* Creating a section that lists out regular pages by year */ -}} {{ range $.Site.RegularPages.GroupByPublishDate &#34;2006&#34; }} {{- /* 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 &#34;main&#34; -}} &lt;h1&gt;{{ .Title }}&lt;/h1&gt; {{ .Content }} &lt;hr&gt; {{- /* Creating a section that lists out regular pages by year */ -}} {{ range $.Site.RegularPages.GroupByPublishDate &#34;2006&#34; }} {{- /* 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:section" content="recipes" />
<meta property="article:published_time" content="2020-10-20T20:36:55+08:00" />
<meta property="article:modified_time" content="2022-05-13T18:08:06+08:00" />
<meta itemprop="name" content="Creating an archive page">
<meta itemprop="description" content="This will add an archive page similar to archive pages like these.
{{- define &#34;main&#34; -}} &lt;h1&gt;{{ .Title }}&lt;/h1&gt; {{ .Content }} &lt;hr&gt; {{- /* Creating a section that lists out regular pages by year */ -}} {{ range $.Site.RegularPages.GroupByPublishDate &#34;2006&#34; }} {{- /* 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 itemprop="datePublished" content="2020-10-20T20:36:55+08:00" />
<meta itemprop="dateModified" content="2022-05-13T18:08:06+08:00" />
<meta itemprop="wordCount" content="233">
<meta itemprop="keywords" content="" /><link rel="canonical" type="text/html" href="https://foo-dogsquared.github.io/hugo-theme-contentful/recipes/creating-an-archive-page/" />
<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>
</nav>
<article>
<header>
<h1>Creating an archive page</h1>
</header>
<div class="post__meta--single">
<p data-content-publication-date="2020-10-20 20:36:55 &#43;0800 &#43;0800">Created: <time datetime="2020-10-20">2020-10-20</time></p>
<p data-content-modification-date="2022-05-13 18:08:06 &#43;0800 &#43;0800">Updated: <time datetime="2022-05-13">2022-05-13</time></p>
</div>
<hr>
<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 &#34;main&#34; -}}
&lt;h1&gt;{{ .Title }}&lt;/h1&gt;
{{ .Content }}
&lt;hr&gt;
{{- /* Creating a section that lists out regular pages by year */ -}}
{{ range $.Site.RegularPages.GroupByPublishDate &#34;2006&#34; }}
{{- /* 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 &#34;0001&#34; }}
&lt;section data-year=&#34;{{ .Key }}&#34;&gt;
&lt;h2 id=&#34;{{ .Key }}&#34;&gt;{{ .Key }}&lt;/h2&gt;
&lt;ul&gt;
{{- range where .Pages &#34;Params.hidden&#34; &#34;!=&#34; true -}}
&lt;li&gt;
&lt;date&gt;{{ .Date.Format &#34;2006-01-02&#34; }}&lt;/date&gt; -
&lt;a aria-label=&#34;{{ .Title }}&#34; href=&#34;{{ .Permalink }}&#34;&gt;{{ .Title }}&lt;/a&gt;
&lt;/li&gt;
{{- end -}}
&lt;/ul&gt;
&lt;/section&gt;
{{- end }}
{{ end }}
{{- end -}}</code></pre>
</div>
</div>
<div class="paragraph">
<p>We will simply add this as a layout in our customized theme.
Lets 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 well 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>, Im 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: &#34;Archives&#34;
layout: &#34;archive&#34;
---
= 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>© 2022 Contentful</p>
</body>
</html>