order oldest to newest hackbook, dates + blog post
This commit is contained in:
parent
6f4a36c6c8
commit
76897fe3df
25 changed files with 1168 additions and 84 deletions
|
@ -8,6 +8,7 @@ pluralizelisttitles = false
|
||||||
showrss = true
|
showrss = true
|
||||||
nextprev = true
|
nextprev = true
|
||||||
taglist = true
|
taglist = true
|
||||||
|
datesinlist = true
|
||||||
|
|
||||||
[markup]
|
[markup]
|
||||||
[markup.goldmark]
|
[markup.goldmark]
|
||||||
|
|
|
@ -11,6 +11,6 @@
|
||||||
|
|
||||||
### [Hackbook EasyPeasy](/hackbook)
|
### [Hackbook EasyPeasy](/hackbook)
|
||||||
|
|
||||||
{{< img src=/img/wip.gif >}}
|
{{< img src=/img/wip.gif alt="Work in progress">}}
|
||||||
|
|
||||||
{{% /center %}}
|
{{% /center %}}
|
126
new-site/content/blog/multiple-index-pages-in-hugo.md
Normal file
126
new-site/content/blog/multiple-index-pages-in-hugo.md
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
---
|
||||||
|
title: "Multiple Index Pages in Hugo"
|
||||||
|
date: 2023-01-03T22:36:03+02:00
|
||||||
|
draft: false
|
||||||
|
tags: ["blog"]
|
||||||
|
---
|
||||||
|
{{% center %}}
|
||||||
|
## This is how to create multiple index pages in Hugo
|
||||||
|
{{% /center %}}
|
||||||
|
|
||||||
|
I wanted to order [Hackbook](/hackbook) in reverse (i.e. oldest to newest) so that it's easier for the reader to start at the correct page.
|
||||||
|
|
||||||
|
I ran into the following problem - the default **```list.html```** does them from newest to oldest.
|
||||||
|
|
||||||
|
So I found [this forum post](https://discourse.gohugo.io/t/two-home-pages/31312/9) and I created a file in the **```_default```** directory as follows:
|
||||||
|
```
|
||||||
|
layouts
|
||||||
|
|----**_default**
|
||||||
|
|-------**hackbook**
|
||||||
|
|-----------**order-by-oldest.html**
|
||||||
|
|-------baseof.html
|
||||||
|
|-------index.html
|
||||||
|
|-------list.html
|
||||||
|
|-------single.html
|
||||||
|
```
|
||||||
|
|
||||||
|
{{< img src=/img/custom-index-directory.PNG alt="Picture of the directory">}}
|
||||||
|
|
||||||
|
|
||||||
|
I named my file order by oldest because I plan on reusing it in other places. This is what's contained inside it:
|
||||||
|
```
|
||||||
|
{{ define "title" -}}
|
||||||
|
{{ .Title | title }}
|
||||||
|
{{- end }}
|
||||||
|
{{ define "main" -}}
|
||||||
|
{{ .Content }}
|
||||||
|
<ul>
|
||||||
|
{{- range.Pages.Reverse }}
|
||||||
|
<li>
|
||||||
|
{{- if .Param "datesinlist" }}<time datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Date.Format "2006 Jan 02" }}</time> – {{ end -}}
|
||||||
|
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
|
||||||
|
{{- if .Param "authorsinlist" }}
|
||||||
|
{{- range .Param "authors" }} by {{ . }}{{ end -}}
|
||||||
|
{{ end -}}
|
||||||
|
</li>
|
||||||
|
{{- end }}
|
||||||
|
</ul>
|
||||||
|
{{- end }}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### if you want to display the date on the left of the titles, you have to add **```datesinlist=true```** in your config.toml or **```datesinlist: true```** in your config.yaml
|
||||||
|
|
||||||
|
##### You probably don't need **```enableGitInfo = true```** as that will crash your website, I have no idea what it does, you don't need it.
|
||||||
|
|
||||||
|
{{% center %}}
|
||||||
|
## Using your custom _index.html
|
||||||
|
{{% /center %}}
|
||||||
|
|
||||||
|
After creating your custom _index.html you'd use it as follows:
|
||||||
|
|
||||||
|
1. Create an _index.md file in your desired directory
|
||||||
|
2. Add **```layout: "hackbook/order-by-oldest"```** to your preamble (if you named your folder and or file something else, you have to change it here)
|
||||||
|
|
||||||
|
{{< img src=/img/layout-custom-index.PNG alt="Picture of the layout in the preamble">}}
|
||||||
|
|
||||||
|
And now you should have a custom _index.html for your pages! :)
|
||||||
|
|
||||||
|
Here is a verbose copy paste of the original hugo forum answer in case it gets deleted:
|
||||||
|
|
||||||
|
```
|
||||||
|
Content structure:
|
||||||
|
|
||||||
|
content
|
||||||
|
├── better
|
||||||
|
│ └── _index.md
|
||||||
|
├── post
|
||||||
|
│ ├── post-1.md
|
||||||
|
│ ├── post-2.md
|
||||||
|
│ └── post-3.md
|
||||||
|
└── _index.md
|
||||||
|
|
||||||
|
content/better/_index.md
|
||||||
|
|
||||||
|
+++
|
||||||
|
title = "Better"
|
||||||
|
date = 2021-03-04T17:02:42-08:00
|
||||||
|
draft = false
|
||||||
|
type = "post"
|
||||||
|
layout = "posts-by-lastmod"
|
||||||
|
+++
|
||||||
|
|
||||||
|
Template structure:
|
||||||
|
|
||||||
|
layouts
|
||||||
|
├── _default
|
||||||
|
│ ├── baseof.html
|
||||||
|
│ ├── list.html
|
||||||
|
│ └── single.html
|
||||||
|
├── post
|
||||||
|
│ └── posts-by-lastmod.html
|
||||||
|
└── index.html
|
||||||
|
|
||||||
|
layouts/post/posts-by-lastmod.html
|
||||||
|
|
||||||
|
{{ define "main" }}
|
||||||
|
{{ .Content }}
|
||||||
|
{{ range (where .Site.RegularPages "Type" "post").ByLastmod.Reverse }}
|
||||||
|
<h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
layouts/index.html
|
||||||
|
|
||||||
|
{{ define "main" }}
|
||||||
|
{{ .Content }}
|
||||||
|
{{ range (where .Site.RegularPages "Type" "post").ByDate.Reverse }}
|
||||||
|
<h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
config.toml (see https://gohugo.io/variables/git/#lastmod)
|
||||||
|
|
||||||
|
enableGitInfo = true
|
||||||
|
|
||||||
|
|
||||||
|
```
|
7
new-site/content/hackbook/_index.md
Normal file
7
new-site/content/hackbook/_index.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
title: "Hackbook EasyPeasy"
|
||||||
|
date: 2023-01-03T22:32:11+02:00
|
||||||
|
draft: false
|
||||||
|
layout: "hackbook/order-by-oldest"
|
||||||
|
---
|
||||||
|
|
|
@ -17,8 +17,9 @@
|
||||||
<article>
|
<article>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="/blog/yoinked-css/">Yoinked some Css and updated the site</a></li>
|
<li><time datetime="2023-01-03T22:36:03+02:00">2023 Jan 03</time> – <a href="/blog/multiple-index-pages-in-hugo/">Multiple Index Pages in Hugo</a></li>
|
||||||
<li><a href="/blog/pluralization-issues/">Pluralization issues (Blogs instead of Blog)</a></li>
|
<li><time datetime="2022-12-27T14:24:24+02:00">2022 Dec 27</time> – <a href="/blog/yoinked-css/">Yoinked some Css and updated the site</a></li>
|
||||||
|
<li><time datetime="2022-12-17T22:33:25+02:00">2022 Dec 17</time> – <a href="/blog/pluralization-issues/">Pluralization issues (Blogs instead of Blog)</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
|
@ -5,11 +5,123 @@
|
||||||
<description>Recent content in Blog on vodoraslo</description>
|
<description>Recent content in Blog on vodoraslo</description>
|
||||||
<generator>Hugo -- gohugo.io</generator>
|
<generator>Hugo -- gohugo.io</generator>
|
||||||
<language>en-us</language>
|
<language>en-us</language>
|
||||||
<lastBuildDate>Tue, 27 Dec 2022 14:24:24 +0200</lastBuildDate>
|
<lastBuildDate>Tue, 03 Jan 2023 22:36:03 +0200</lastBuildDate>
|
||||||
|
|
||||||
<atom:link href="https://vodoraslo.xyz/blog/index.xml" rel="self" type="application/rss+xml" />
|
<atom:link href="https://vodoraslo.xyz/blog/index.xml" rel="self" type="application/rss+xml" />
|
||||||
|
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<title>Multiple Index Pages in Hugo</title>
|
||||||
|
<link>https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/</link>
|
||||||
|
<pubDate>Tue, 03 Jan 2023 22:36:03 +0200</pubDate>
|
||||||
|
|
||||||
|
<guid>https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/</guid>
|
||||||
|
<description><div style="text-align: center;">
|
||||||
|
<h2 id="this-is-how-to-create-multiple-index-pages-in-hugo">This is how to create multiple index pages in Hugo</h2>
|
||||||
|
</div>
|
||||||
|
<p>I wanted to order <a href="https://vodoraslo.xyz/hackbook">Hackbook</a> in reverse (i.e. oldest to newest) so that it&rsquo;s easier for the reader to start at the correct page.</p>
|
||||||
|
<p>I ran into the following problem - the default <strong><code>list.html</code></strong> does them from newest to oldest.</p>
|
||||||
|
<p>So I found <a href="https://discourse.gohugo.io/t/two-home-pages/31312/9">this forum post</a> and I created a file in the <strong><code>_default</code></strong> directory as follows:</p>
|
||||||
|
<pre tabindex="0"><code>layouts
|
||||||
|
|----**_default**
|
||||||
|
|-------**hackbook**
|
||||||
|
|-----------**order-by-oldest.html**
|
||||||
|
|-------baseof.html
|
||||||
|
|-------index.html
|
||||||
|
|-------list.html
|
||||||
|
|-------single.html
|
||||||
|
</code></pre>
|
||||||
|
<figure ><img src="https://vodoraslo.xyz/img/custom-index-directory.PNG" alt="Picture of the directory"></figure>
|
||||||
|
|
||||||
|
<p>I named my file order by oldest because I plan on reusing it in other places. This is what&rsquo;s contained inside it:</p>
|
||||||
|
<pre tabindex="0"><code>{{ define &#34;title&#34; -}}
|
||||||
|
{{ .Title | title }}
|
||||||
|
{{- end }}
|
||||||
|
{{ define &#34;main&#34; -}}
|
||||||
|
{{ .Content }}
|
||||||
|
&lt;ul&gt;
|
||||||
|
{{- range.Pages.Reverse }}
|
||||||
|
&lt;li&gt;
|
||||||
|
{{- if .Param &#34;datesinlist&#34; }}&lt;time datetime=&#34;{{ .Date.Format &#34;2006-01-02T15:04:05Z07:00&#34; }}&#34;&gt;{{ .Date.Format &#34;2006 Jan 02&#34; }}&lt;/time&gt; &amp;ndash; {{ end -}}
|
||||||
|
&lt;a href=&#34;{{ .RelPermalink }}&#34;&gt;{{ .Title }}&lt;/a&gt;
|
||||||
|
{{- if .Param &#34;authorsinlist&#34; }}
|
||||||
|
{{- range .Param &#34;authors&#34; }} by {{ . }}{{ end -}}
|
||||||
|
{{ end -}}
|
||||||
|
&lt;/li&gt;
|
||||||
|
{{- end }}
|
||||||
|
&lt;/ul&gt;
|
||||||
|
{{- end }}
|
||||||
|
</code></pre><h4 id="if-you-want-to-display-the-date-on-the-left-of-the-titles-you-have-to-add-datesinlisttrue-in-your-configtoml-or-datesinlist-true-in-your-configyaml">if you want to display the date on the left of the titles, you have to add <strong><code>datesinlist=true</code></strong> in your config.toml or <strong><code>datesinlist: true</code></strong> in your config.yaml</h4>
|
||||||
|
<h5 id="you-probably-dont-need-enablegitinfo--true-as-that-will-crash-your-website-i-have-no-idea-what-it-does-you-dont-need-it">You probably don&rsquo;t need <strong><code>enableGitInfo = true</code></strong> as that will crash your website, I have no idea what it does, you don&rsquo;t need it.</h5>
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<h2 id="using-your-custom-_indexhtml">Using your custom _index.html</h2>
|
||||||
|
</div>
|
||||||
|
<p>After creating your custom _index.html you&rsquo;d use it as follows:</p>
|
||||||
|
<ol>
|
||||||
|
<li>Create an _index.md file in your desired directory</li>
|
||||||
|
<li>Add <strong><code>layout: &quot;hackbook/order-by-oldest&quot;</code></strong> to your preamble (if you named your folder and or file something else, you have to change it here)</li>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
<figure ><img src="https://vodoraslo.xyz/img/layout-custom-index.PNG" alt="Picture of the layout in the preamble"></figure>
|
||||||
|
|
||||||
|
<p>And now you should have a custom _index.html for your pages! :)</p>
|
||||||
|
<p>Here is a verbose copy paste of the original hugo forum answer in case it gets deleted:</p>
|
||||||
|
<pre tabindex="0"><code>Content structure:
|
||||||
|
|
||||||
|
content
|
||||||
|
├── better
|
||||||
|
│ └── _index.md
|
||||||
|
├── post
|
||||||
|
│ ├── post-1.md
|
||||||
|
│ ├── post-2.md
|
||||||
|
│ └── post-3.md
|
||||||
|
└── _index.md
|
||||||
|
|
||||||
|
content/better/_index.md
|
||||||
|
|
||||||
|
+++
|
||||||
|
title = &#34;Better&#34;
|
||||||
|
date = 2021-03-04T17:02:42-08:00
|
||||||
|
draft = false
|
||||||
|
type = &#34;post&#34;
|
||||||
|
layout = &#34;posts-by-lastmod&#34;
|
||||||
|
+++
|
||||||
|
|
||||||
|
Template structure:
|
||||||
|
|
||||||
|
layouts
|
||||||
|
├── _default
|
||||||
|
│ ├── baseof.html
|
||||||
|
│ ├── list.html
|
||||||
|
│ └── single.html
|
||||||
|
├── post
|
||||||
|
│ └── posts-by-lastmod.html
|
||||||
|
└── index.html
|
||||||
|
|
||||||
|
layouts/post/posts-by-lastmod.html
|
||||||
|
|
||||||
|
{{ define &#34;main&#34; }}
|
||||||
|
{{ .Content }}
|
||||||
|
{{ range (where .Site.RegularPages &#34;Type&#34; &#34;post&#34;).ByLastmod.Reverse }}
|
||||||
|
&lt;h2&gt;&lt;a href=&#34;{{ .RelPermalink }}&#34;&gt;{{ .Title }}&lt;/a&gt;&lt;/h2&gt;
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
layouts/index.html
|
||||||
|
|
||||||
|
{{ define &#34;main&#34; }}
|
||||||
|
{{ .Content }}
|
||||||
|
{{ range (where .Site.RegularPages &#34;Type&#34; &#34;post&#34;).ByDate.Reverse }}
|
||||||
|
&lt;h2&gt;&lt;a href=&#34;{{ .RelPermalink }}&#34;&gt;{{ .Title }}&lt;/a&gt;&lt;/h2&gt;
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
config.toml (see https://gohugo.io/variables/git/#lastmod)
|
||||||
|
|
||||||
|
enableGitInfo = true
|
||||||
|
</code></pre></description>
|
||||||
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<title>Yoinked some Css and updated the site</title>
|
<title>Yoinked some Css and updated the site</title>
|
||||||
<link>https://vodoraslo.xyz/blog/yoinked-css/</link>
|
<link>https://vodoraslo.xyz/blog/yoinked-css/</link>
|
||||||
|
|
143
new-site/public/blog/multiple-index-pages-in-hugo/index.html
Normal file
143
new-site/public/blog/multiple-index-pages-in-hugo/index.html
Normal file
|
@ -0,0 +1,143 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>Multiple Index Pages in Hugo | vodoraslo</title>
|
||||||
|
<link rel="canonical" href="https://vodoraslo.xyz/">
|
||||||
|
<link rel='alternate' type='application/rss+xml' title="vodoraslo RSS" href='/index.xml'>
|
||||||
|
<link rel='stylesheet' type='text/css' href='/style.css'>
|
||||||
|
<link rel="icon" href="/favicon.ico">
|
||||||
|
<meta name="description" content="This is how to create multiple index pages in Hugo I wanted to order Hackbook in reverse (i.e. oldest to newest) so that it’s easier for the reader to start at the correct page.
|
||||||
|
I ran into the following problem - the default list.html does them from newest to oldest.
|
||||||
|
So I found this forum post and I created a file in the _default directory as follows:
|
||||||
|
layouts |----**_default** |-------**hackbook** |-----------**order-by-oldest.">
|
||||||
|
<meta name="keywords" content="blog">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<meta name="robots" content="index, follow">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main>
|
||||||
|
<header><h1 id="tag_Multiple Index Pages in Hugo">Multiple Index Pages in Hugo</h1></header>
|
||||||
|
<article>
|
||||||
|
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<h2 id="this-is-how-to-create-multiple-index-pages-in-hugo">This is how to create multiple index pages in Hugo</h2>
|
||||||
|
</div>
|
||||||
|
<p>I wanted to order <a href="/hackbook">Hackbook</a> in reverse (i.e. oldest to newest) so that it’s easier for the reader to start at the correct page.</p>
|
||||||
|
<p>I ran into the following problem - the default <strong><code>list.html</code></strong> does them from newest to oldest.</p>
|
||||||
|
<p>So I found <a href="https://discourse.gohugo.io/t/two-home-pages/31312/9">this forum post</a> and I created a file in the <strong><code>_default</code></strong> directory as follows:</p>
|
||||||
|
<pre tabindex="0"><code>layouts
|
||||||
|
|----**_default**
|
||||||
|
|-------**hackbook**
|
||||||
|
|-----------**order-by-oldest.html**
|
||||||
|
|-------baseof.html
|
||||||
|
|-------index.html
|
||||||
|
|-------list.html
|
||||||
|
|-------single.html
|
||||||
|
</code></pre>
|
||||||
|
<figure ><img src="/img/custom-index-directory.PNG" alt="Picture of the directory"></figure>
|
||||||
|
|
||||||
|
<p>I named my file order by oldest because I plan on reusing it in other places. This is what’s contained inside it:</p>
|
||||||
|
<pre tabindex="0"><code>{{ define "title" -}}
|
||||||
|
{{ .Title | title }}
|
||||||
|
{{- end }}
|
||||||
|
{{ define "main" -}}
|
||||||
|
{{ .Content }}
|
||||||
|
<ul>
|
||||||
|
{{- range.Pages.Reverse }}
|
||||||
|
<li>
|
||||||
|
{{- if .Param "datesinlist" }}<time datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Date.Format "2006 Jan 02" }}</time> &ndash; {{ end -}}
|
||||||
|
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
|
||||||
|
{{- if .Param "authorsinlist" }}
|
||||||
|
{{- range .Param "authors" }} by {{ . }}{{ end -}}
|
||||||
|
{{ end -}}
|
||||||
|
</li>
|
||||||
|
{{- end }}
|
||||||
|
</ul>
|
||||||
|
{{- end }}
|
||||||
|
</code></pre><h4 id="if-you-want-to-display-the-date-on-the-left-of-the-titles-you-have-to-add-datesinlisttrue-in-your-configtoml-or-datesinlist-true-in-your-configyaml">if you want to display the date on the left of the titles, you have to add <strong><code>datesinlist=true</code></strong> in your config.toml or <strong><code>datesinlist: true</code></strong> in your config.yaml</h4>
|
||||||
|
<h5 id="you-probably-dont-need-enablegitinfo--true-as-that-will-crash-your-website-i-have-no-idea-what-it-does-you-dont-need-it">You probably don’t need <strong><code>enableGitInfo = true</code></strong> as that will crash your website, I have no idea what it does, you don’t need it.</h5>
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<h2 id="using-your-custom-_indexhtml">Using your custom _index.html</h2>
|
||||||
|
</div>
|
||||||
|
<p>After creating your custom _index.html you’d use it as follows:</p>
|
||||||
|
<ol>
|
||||||
|
<li>Create an _index.md file in your desired directory</li>
|
||||||
|
<li>Add <strong><code>layout: "hackbook/order-by-oldest"</code></strong> to your preamble (if you named your folder and or file something else, you have to change it here)</li>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
<figure ><img src="/img/layout-custom-index.PNG" alt="Picture of the layout in the preamble"></figure>
|
||||||
|
|
||||||
|
<p>And now you should have a custom _index.html for your pages! :)</p>
|
||||||
|
<p>Here is a verbose copy paste of the original hugo forum answer in case it gets deleted:</p>
|
||||||
|
<pre tabindex="0"><code>Content structure:
|
||||||
|
|
||||||
|
content
|
||||||
|
├── better
|
||||||
|
│ └── _index.md
|
||||||
|
├── post
|
||||||
|
│ ├── post-1.md
|
||||||
|
│ ├── post-2.md
|
||||||
|
│ └── post-3.md
|
||||||
|
└── _index.md
|
||||||
|
|
||||||
|
content/better/_index.md
|
||||||
|
|
||||||
|
+++
|
||||||
|
title = "Better"
|
||||||
|
date = 2021-03-04T17:02:42-08:00
|
||||||
|
draft = false
|
||||||
|
type = "post"
|
||||||
|
layout = "posts-by-lastmod"
|
||||||
|
+++
|
||||||
|
|
||||||
|
Template structure:
|
||||||
|
|
||||||
|
layouts
|
||||||
|
├── _default
|
||||||
|
│ ├── baseof.html
|
||||||
|
│ ├── list.html
|
||||||
|
│ └── single.html
|
||||||
|
├── post
|
||||||
|
│ └── posts-by-lastmod.html
|
||||||
|
└── index.html
|
||||||
|
|
||||||
|
layouts/post/posts-by-lastmod.html
|
||||||
|
|
||||||
|
{{ define "main" }}
|
||||||
|
{{ .Content }}
|
||||||
|
{{ range (where .Site.RegularPages "Type" "post").ByLastmod.Reverse }}
|
||||||
|
<h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
layouts/index.html
|
||||||
|
|
||||||
|
{{ define "main" }}
|
||||||
|
{{ .Content }}
|
||||||
|
{{ range (where .Site.RegularPages "Type" "post").ByDate.Reverse }}
|
||||||
|
<h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
config.toml (see https://gohugo.io/variables/git/#lastmod)
|
||||||
|
|
||||||
|
enableGitInfo = true
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<div id="nextprev">
|
||||||
|
<a href="/blog/yoinked-css/"><div id="prevart">Previous:<br>Yoinked some Css and updated the site</div></a>
|
||||||
|
</div>
|
||||||
|
<div style="clear:both" class=taglist>
|
||||||
|
Tags: [<a id="tag_blog" href="https://vodoraslo.xyz/tags/blog">Blog</a>]
|
||||||
|
</div>
|
||||||
|
<br><br>
|
||||||
|
</article>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
<a href="https://vodoraslo.xyz/">Homepage</a><br><br><a href="/index.xml"><img src="/rss.svg" style="max-height:1.5em" alt="RSS Feed" title="Subscribe via RSS for updates."></a>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
<div id="nextprev">
|
<div id="nextprev">
|
||||||
<a href="/hackbook/fin/"><div id="prevart">Previous:<br>Fin</div></a>
|
<a href="/hackbook/fin/"><div id="prevart">Previous:<br>Fin</div></a>
|
||||||
|
<a href="/blog/multiple-index-pages-in-hugo/"><div id="nextart">Next:<br>Multiple Index Pages in Hugo</div></a>
|
||||||
</div>
|
</div>
|
||||||
<div style="clear:both" class=taglist>
|
<div style="clear:both" class=taglist>
|
||||||
Tags: [<a id="tag_updates" href="https://vodoraslo.xyz/tags/updates">Updates</a>]
|
Tags: [<a id="tag_updates" href="https://vodoraslo.xyz/tags/updates">Updates</a>]
|
||||||
|
|
|
@ -9,6 +9,118 @@
|
||||||
<atom:link href="https://vodoraslo.xyz/categories/index.xml" rel="self" type="application/rss+xml" />
|
<atom:link href="https://vodoraslo.xyz/categories/index.xml" rel="self" type="application/rss+xml" />
|
||||||
|
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<title>Multiple Index Pages in Hugo</title>
|
||||||
|
<link>https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/</link>
|
||||||
|
<pubDate>Tue, 03 Jan 2023 22:36:03 +0200</pubDate>
|
||||||
|
|
||||||
|
<guid>https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/</guid>
|
||||||
|
<description><div style="text-align: center;">
|
||||||
|
<h2 id="this-is-how-to-create-multiple-index-pages-in-hugo">This is how to create multiple index pages in Hugo</h2>
|
||||||
|
</div>
|
||||||
|
<p>I wanted to order <a href="https://vodoraslo.xyz/hackbook">Hackbook</a> in reverse (i.e. oldest to newest) so that it&rsquo;s easier for the reader to start at the correct page.</p>
|
||||||
|
<p>I ran into the following problem - the default <strong><code>list.html</code></strong> does them from newest to oldest.</p>
|
||||||
|
<p>So I found <a href="https://discourse.gohugo.io/t/two-home-pages/31312/9">this forum post</a> and I created a file in the <strong><code>_default</code></strong> directory as follows:</p>
|
||||||
|
<pre tabindex="0"><code>layouts
|
||||||
|
|----**_default**
|
||||||
|
|-------**hackbook**
|
||||||
|
|-----------**order-by-oldest.html**
|
||||||
|
|-------baseof.html
|
||||||
|
|-------index.html
|
||||||
|
|-------list.html
|
||||||
|
|-------single.html
|
||||||
|
</code></pre>
|
||||||
|
<figure ><img src="https://vodoraslo.xyz/img/custom-index-directory.PNG" alt="Picture of the directory"></figure>
|
||||||
|
|
||||||
|
<p>I named my file order by oldest because I plan on reusing it in other places. This is what&rsquo;s contained inside it:</p>
|
||||||
|
<pre tabindex="0"><code>{{ define &#34;title&#34; -}}
|
||||||
|
{{ .Title | title }}
|
||||||
|
{{- end }}
|
||||||
|
{{ define &#34;main&#34; -}}
|
||||||
|
{{ .Content }}
|
||||||
|
&lt;ul&gt;
|
||||||
|
{{- range.Pages.Reverse }}
|
||||||
|
&lt;li&gt;
|
||||||
|
{{- if .Param &#34;datesinlist&#34; }}&lt;time datetime=&#34;{{ .Date.Format &#34;2006-01-02T15:04:05Z07:00&#34; }}&#34;&gt;{{ .Date.Format &#34;2006 Jan 02&#34; }}&lt;/time&gt; &amp;ndash; {{ end -}}
|
||||||
|
&lt;a href=&#34;{{ .RelPermalink }}&#34;&gt;{{ .Title }}&lt;/a&gt;
|
||||||
|
{{- if .Param &#34;authorsinlist&#34; }}
|
||||||
|
{{- range .Param &#34;authors&#34; }} by {{ . }}{{ end -}}
|
||||||
|
{{ end -}}
|
||||||
|
&lt;/li&gt;
|
||||||
|
{{- end }}
|
||||||
|
&lt;/ul&gt;
|
||||||
|
{{- end }}
|
||||||
|
</code></pre><h4 id="if-you-want-to-display-the-date-on-the-left-of-the-titles-you-have-to-add-datesinlisttrue-in-your-configtoml-or-datesinlist-true-in-your-configyaml">if you want to display the date on the left of the titles, you have to add <strong><code>datesinlist=true</code></strong> in your config.toml or <strong><code>datesinlist: true</code></strong> in your config.yaml</h4>
|
||||||
|
<h5 id="you-probably-dont-need-enablegitinfo--true-as-that-will-crash-your-website-i-have-no-idea-what-it-does-you-dont-need-it">You probably don&rsquo;t need <strong><code>enableGitInfo = true</code></strong> as that will crash your website, I have no idea what it does, you don&rsquo;t need it.</h5>
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<h2 id="using-your-custom-_indexhtml">Using your custom _index.html</h2>
|
||||||
|
</div>
|
||||||
|
<p>After creating your custom _index.html you&rsquo;d use it as follows:</p>
|
||||||
|
<ol>
|
||||||
|
<li>Create an _index.md file in your desired directory</li>
|
||||||
|
<li>Add <strong><code>layout: &quot;hackbook/order-by-oldest&quot;</code></strong> to your preamble (if you named your folder and or file something else, you have to change it here)</li>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
<figure ><img src="https://vodoraslo.xyz/img/layout-custom-index.PNG" alt="Picture of the layout in the preamble"></figure>
|
||||||
|
|
||||||
|
<p>And now you should have a custom _index.html for your pages! :)</p>
|
||||||
|
<p>Here is a verbose copy paste of the original hugo forum answer in case it gets deleted:</p>
|
||||||
|
<pre tabindex="0"><code>Content structure:
|
||||||
|
|
||||||
|
content
|
||||||
|
├── better
|
||||||
|
│ └── _index.md
|
||||||
|
├── post
|
||||||
|
│ ├── post-1.md
|
||||||
|
│ ├── post-2.md
|
||||||
|
│ └── post-3.md
|
||||||
|
└── _index.md
|
||||||
|
|
||||||
|
content/better/_index.md
|
||||||
|
|
||||||
|
+++
|
||||||
|
title = &#34;Better&#34;
|
||||||
|
date = 2021-03-04T17:02:42-08:00
|
||||||
|
draft = false
|
||||||
|
type = &#34;post&#34;
|
||||||
|
layout = &#34;posts-by-lastmod&#34;
|
||||||
|
+++
|
||||||
|
|
||||||
|
Template structure:
|
||||||
|
|
||||||
|
layouts
|
||||||
|
├── _default
|
||||||
|
│ ├── baseof.html
|
||||||
|
│ ├── list.html
|
||||||
|
│ └── single.html
|
||||||
|
├── post
|
||||||
|
│ └── posts-by-lastmod.html
|
||||||
|
└── index.html
|
||||||
|
|
||||||
|
layouts/post/posts-by-lastmod.html
|
||||||
|
|
||||||
|
{{ define &#34;main&#34; }}
|
||||||
|
{{ .Content }}
|
||||||
|
{{ range (where .Site.RegularPages &#34;Type&#34; &#34;post&#34;).ByLastmod.Reverse }}
|
||||||
|
&lt;h2&gt;&lt;a href=&#34;{{ .RelPermalink }}&#34;&gt;{{ .Title }}&lt;/a&gt;&lt;/h2&gt;
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
layouts/index.html
|
||||||
|
|
||||||
|
{{ define &#34;main&#34; }}
|
||||||
|
{{ .Content }}
|
||||||
|
{{ range (where .Site.RegularPages &#34;Type&#34; &#34;post&#34;).ByDate.Reverse }}
|
||||||
|
&lt;h2&gt;&lt;a href=&#34;{{ .RelPermalink }}&#34;&gt;{{ .Title }}&lt;/a&gt;&lt;/h2&gt;
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
config.toml (see https://gohugo.io/variables/git/#lastmod)
|
||||||
|
|
||||||
|
enableGitInfo = true
|
||||||
|
</code></pre></description>
|
||||||
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<title>Yoinked some Css and updated the site</title>
|
<title>Yoinked some Css and updated the site</title>
|
||||||
<link>https://vodoraslo.xyz/blog/yoinked-css/</link>
|
<link>https://vodoraslo.xyz/blog/yoinked-css/</link>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>Hackbook | vodoraslo</title>
|
<title>Hackbook EasyPeasy | vodoraslo</title>
|
||||||
<link rel="canonical" href="https://vodoraslo.xyz/">
|
<link rel="canonical" href="https://vodoraslo.xyz/">
|
||||||
<link rel='alternate' type='application/rss+xml' title="vodoraslo RSS" href='/index.xml'>
|
<link rel='alternate' type='application/rss+xml' title="vodoraslo RSS" href='/index.xml'>
|
||||||
<link rel='stylesheet' type='text/css' href='/style.css'>
|
<link rel='stylesheet' type='text/css' href='/style.css'>
|
||||||
|
@ -13,68 +13,68 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main>
|
<main>
|
||||||
<header><h1 id="tag_Hackbook">Hackbook</h1></header>
|
<header><h1 id="tag_Hackbook EasyPeasy">Hackbook EasyPeasy</h1></header>
|
||||||
<article>
|
<article>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="/hackbook/fin/">Fin</a></li>
|
<li><time datetime="2022-12-19T22:01:36+02:00">2022 Dec 19</time> – <a href="/hackbook/00-00-hackbookeasypeasy/">00-00 HackBook EasyPeasy</a></li>
|
||||||
<li><a href="/hackbook/05-01-scripts-05/">05-01 Scripts-05</a></li>
|
<li><time datetime="2022-12-19T22:14:52+02:00">2022 Dec 19</time> – <a href="/hackbook/01-01-preface/">01-01 Preface</a></li>
|
||||||
<li><a href="/hackbook/05-01-scripts-04/">05-01 Scripts-04</a></li>
|
<li><time datetime="2022-12-19T22:19:35+02:00">2022 Dec 19</time> – <a href="/hackbook/01-02-warning/">01-02 Warning</a></li>
|
||||||
<li><a href="/hackbook/05-01-scripts-03/">05-01 Scripts-03</a></li>
|
<li><time datetime="2022-12-19T22:23:44+02:00">2022 Dec 19</time> – <a href="/hackbook/01-03-fear/">01-03 Fear</a></li>
|
||||||
<li><a href="/hackbook/05-01-scripts-02/">05-01 Scripts-02</a></li>
|
<li><time datetime="2022-12-19T22:27:57+02:00">2022 Dec 19</time> – <a href="/hackbook/02-01-introduction/">02-01 Introduction</a></li>
|
||||||
<li><a href="/hackbook/05-01-scripts-01/">05-01 Scripts-01</a></li>
|
<li><time datetime="2022-12-20T16:58:54+02:00">2022 Dec 20</time> – <a href="/hackbook/02-02-sister-kenny/">02-02 Sister Kenny</a></li>
|
||||||
<li><a href="/hackbook/04-02-rebt-coping-statements/">04-02 REBT_Coping_Statements</a></li>
|
<li><time datetime="2022-12-20T17:10:39+02:00">2022 Dec 20</time> – <a href="/hackbook/03-01-the-worst-pmo-addict-i-have-yet-to-meet/">03-01 the Worst PMO Addict I Have Yet to Meet</a></li>
|
||||||
<li><a href="/hackbook/04-01-the-instructions/">04-01 The Instructions</a></li>
|
<li><time datetime="2022-12-20T20:26:34+02:00">2022 Dec 20</time> – <a href="/hackbook/03-02-the-easy-method/">03-02 the Easy Method</a></li>
|
||||||
<li><a href="/hackbook/03-44-should-i-tell-my-so/">03-44 Should I Tell My SO</a></li>
|
<li><time datetime="2022-12-20T20:31:45+02:00">2022 Dec 20</time> – <a href="/hackbook/03-03-why-is-it-difficult-to-stop/">03-03 Why Is It Difficult to Stop?</a></li>
|
||||||
<li><a href="/hackbook/03-43-advice-to-non-pmoers/">03-43 Advice to Non-PMOers</a></li>
|
<li><time datetime="2022-12-20T20:38:28+02:00">2022 Dec 20</time> – <a href="/hackbook/03-04-the-sinister-trap/">03-04 The Sinister Trap</a></li>
|
||||||
<li><a href="/hackbook/03-42-help-the-pmoer-left-on-the-sinking-ship/">03-42 Help the PMOer Left on the Sinking Ship</a></li>
|
<li><time datetime="2022-12-20T20:42:16+02:00">2022 Dec 20</time> – <a href="/hackbook/03-05-why-do-we-carry-on-with-pmo/">03-05 Why Do We Carry on With PMO</a></li>
|
||||||
<li><a href="/hackbook/03-41-feedback/">03-41 Feedback</a></li>
|
<li><time datetime="2022-12-20T20:44:00+02:00">2022 Dec 20</time> – <a href="/hackbook/03-06-internet-porn/">03-06 Internet Porn</a></li>
|
||||||
<li><a href="/hackbook/03-40-a-final-warning/">03-40 A Final Warning</a></li>
|
<li><time datetime="2022-12-23T08:39:02+02:00">2022 Dec 23</time> – <a href="/hackbook/03-07-brainwashing-and-the-primitive-mechanism/">03-07 Brainwashing and the Primitive Mechanism</a></li>
|
||||||
<li><a href="/hackbook/03-39-the-final-visit/">03-39 The Final Visit</a></li>
|
<li><time datetime="2022-12-23T11:36:16+02:00">2022 Dec 23</time> – <a href="/hackbook/03-08-relieving-withdrawal-pangs/">03-08 Relieving Withdrawal Pangs</a></li>
|
||||||
<li><a href="/hackbook/03-38-the-moment-of-revelation/">03-38 The Moment of Revelation</a></li>
|
<li><time datetime="2022-12-23T11:38:59+02:00">2022 Dec 23</time> – <a href="/hackbook/03-09-stress/">03-09 Stress</a></li>
|
||||||
<li><a href="/hackbook/03-37-should-i-avoid-temptation-situations/">03-37 Should I Avoid Temptation Situations?</a></li>
|
<li><time datetime="2022-12-23T11:40:46+02:00">2022 Dec 23</time> – <a href="/hackbook/03-10-boredom/">03-10 Boredom</a></li>
|
||||||
<li><a href="/hackbook/03-36-substitutes/">03-36 Substitutes</a></li>
|
<li><time datetime="2022-12-23T11:42:13+02:00">2022 Dec 23</time> – <a href="/hackbook/03-11-concentration/">03-11 Concentration</a></li>
|
||||||
<li><a href="/hackbook/03-35-the-main-reasons-for-failure/">03-35 the Main Reasons for Failure</a></li>
|
<li><time datetime="2022-12-23T11:44:10+02:00">2022 Dec 23</time> – <a href="/hackbook/03-12-relaxation/">03-12 Relaxation</a></li>
|
||||||
<li><a href="/hackbook/03-34-will-it-be-harder-for-me/">03-34 Will It Be Harder for Me?</a></li>
|
<li><time datetime="2022-12-23T11:47:03+02:00">2022 Dec 23</time> – <a href="/hackbook/03-13-social-night-pmoing/">03-13 Social Night PMOing</a></li>
|
||||||
<li><a href="/hackbook/03-33-just-one-peek/">03-33 Just One Peek</a></li>
|
<li><time datetime="2022-12-23T11:49:35+02:00">2022 Dec 23</time> – <a href="/hackbook/03-14-what-am-i-giving-up/">03-14 What Am I Giving Up?</a></li>
|
||||||
<li><a href="/hackbook/03-32-the-withdrawal-period/">03-32 The Withdrawal Period</a></li>
|
<li><time datetime="2022-12-23T12:06:39+02:00">2022 Dec 23</time> – <a href="/hackbook/03-15-self-imposed-slavery/">03-15 Self-Imposed Slavery</a></li>
|
||||||
<li><a href="/hackbook/03-31-the-easy-way-to-stop/">03-31 the Easy Way to Stop</a></li>
|
<li><time datetime="2022-12-23T12:08:55+02:00">2022 Dec 23</time> – <a href="/hackbook/03-16-i-will-save-x-hours-a-week/">03-16 I Will Save X Hours a Week</a></li>
|
||||||
<li><a href="/hackbook/03-30-avoid-false-incentives/">03-30 Avoid False Incentives</a></li>
|
<li><time datetime="2022-12-23T12:12:31+02:00">2022 Dec 23</time> – <a href="/hackbook/03-17-health/">03-17 Health</a></li>
|
||||||
<li><a href="/hackbook/03-29-can-i-compartmentalize/">03-29 Can I Compartmentalize?</a></li>
|
<li><time datetime="2022-12-23T23:12:56+02:00">2022 Dec 23</time> – <a href="/hackbook/03-18-energy/">03-18 Energy</a></li>
|
||||||
<li><a href="/hackbook/03-28-will-i-miss-the-fun/">03-28 Will I Miss the Fun?</a></li>
|
<li><time datetime="2022-12-23T23:16:17+02:00">2022 Dec 23</time> – <a href="/hackbook/03-19-it-relaxes-me-and-gives-me-confidence/">03-19 It Relaxes Me and Gives Me Confidence</a></li>
|
||||||
<li><a href="/hackbook/03-27-timing/">03-27 Timing</a></li>
|
<li><time datetime="2022-12-23T23:18:55+02:00">2022 Dec 23</time> – <a href="/hackbook/03-20-those-sinister-black-shadows/">03-20 Those Sinister Black Shadows</a></li>
|
||||||
<li><a href="/hackbook/03-26-a-social-habit/">03-26 A Social Habit?</a></li>
|
<li><time datetime="2022-12-23T23:20:42+02:00">2022 Dec 23</time> – <a href="/hackbook/03-21-the-willpower-method-of-stopping/">03-21 the Willpower Method of Stopping</a></li>
|
||||||
<li><a href="/hackbook/03-25-the-youtube-pmoer/">03-25 The YouTube PMOer</a></li>
|
<li><time datetime="2022-12-23T23:28:58+02:00">2022 Dec 23</time> – <a href="/hackbook/03-22-beware-of-cutting-down/">03-22 Beware of Cutting Down</a></li>
|
||||||
<li><a href="/hackbook/03-24-casual-pmoers-teenagers-non-pmoers/">03-24 Casual PMOers, Teenagers, Non PMOers</a></li>
|
<li><time datetime="2022-12-23T23:35:22+02:00">2022 Dec 23</time> – <a href="/hackbook/03-23-just-one-peek/">03-23 Just One Peek</a></li>
|
||||||
<li><a href="/hackbook/03-23-just-one-peek/">03-23 Just One Peek</a></li>
|
<li><time datetime="2022-12-23T23:40:22+02:00">2022 Dec 23</time> – <a href="/hackbook/03-24-casual-pmoers-teenagers-non-pmoers/">03-24 Casual PMOers, Teenagers, Non PMOers</a></li>
|
||||||
<li><a href="/hackbook/03-22-beware-of-cutting-down/">03-22 Beware of Cutting Down</a></li>
|
<li><time datetime="2022-12-23T23:51:35+02:00">2022 Dec 23</time> – <a href="/hackbook/03-25-the-youtube-pmoer/">03-25 The YouTube PMOer</a></li>
|
||||||
<li><a href="/hackbook/03-21-the-willpower-method-of-stopping/">03-21 the Willpower Method of Stopping</a></li>
|
<li><time datetime="2022-12-23T23:54:03+02:00">2022 Dec 23</time> – <a href="/hackbook/03-26-a-social-habit/">03-26 A Social Habit?</a></li>
|
||||||
<li><a href="/hackbook/03-20-those-sinister-black-shadows/">03-20 Those Sinister Black Shadows</a></li>
|
<li><time datetime="2022-12-23T23:55:57+02:00">2022 Dec 23</time> – <a href="/hackbook/03-27-timing/">03-27 Timing</a></li>
|
||||||
<li><a href="/hackbook/03-19-it-relaxes-me-and-gives-me-confidence/">03-19 It Relaxes Me and Gives Me Confidence</a></li>
|
<li><time datetime="2022-12-24T00:01:03+02:00">2022 Dec 24</time> – <a href="/hackbook/03-28-will-i-miss-the-fun/">03-28 Will I Miss the Fun?</a></li>
|
||||||
<li><a href="/hackbook/03-18-energy/">03-18 Energy</a></li>
|
<li><time datetime="2022-12-24T00:03:34+02:00">2022 Dec 24</time> – <a href="/hackbook/03-29-can-i-compartmentalize/">03-29 Can I Compartmentalize?</a></li>
|
||||||
<li><a href="/hackbook/03-17-health/">03-17 Health</a></li>
|
<li><time datetime="2022-12-24T00:05:14+02:00">2022 Dec 24</time> – <a href="/hackbook/03-30-avoid-false-incentives/">03-30 Avoid False Incentives</a></li>
|
||||||
<li><a href="/hackbook/03-16-i-will-save-x-hours-a-week/">03-16 I Will Save X Hours a Week</a></li>
|
<li><time datetime="2022-12-24T00:07:43+02:00">2022 Dec 24</time> – <a href="/hackbook/03-31-the-easy-way-to-stop/">03-31 the Easy Way to Stop</a></li>
|
||||||
<li><a href="/hackbook/03-15-self-imposed-slavery/">03-15 Self-Imposed Slavery</a></li>
|
<li><time datetime="2022-12-24T00:16:57+02:00">2022 Dec 24</time> – <a href="/hackbook/03-32-the-withdrawal-period/">03-32 The Withdrawal Period</a></li>
|
||||||
<li><a href="/hackbook/03-14-what-am-i-giving-up/">03-14 What Am I Giving Up?</a></li>
|
<li><time datetime="2022-12-24T00:20:57+02:00">2022 Dec 24</time> – <a href="/hackbook/03-33-just-one-peek/">03-33 Just One Peek</a></li>
|
||||||
<li><a href="/hackbook/03-13-social-night-pmoing/">03-13 Social Night PMOing</a></li>
|
<li><time datetime="2022-12-24T00:22:12+02:00">2022 Dec 24</time> – <a href="/hackbook/03-34-will-it-be-harder-for-me/">03-34 Will It Be Harder for Me?</a></li>
|
||||||
<li><a href="/hackbook/03-12-relaxation/">03-12 Relaxation</a></li>
|
<li><time datetime="2022-12-24T00:23:39+02:00">2022 Dec 24</time> – <a href="/hackbook/03-35-the-main-reasons-for-failure/">03-35 the Main Reasons for Failure</a></li>
|
||||||
<li><a href="/hackbook/03-11-concentration/">03-11 Concentration</a></li>
|
<li><time datetime="2022-12-24T08:46:33+02:00">2022 Dec 24</time> – <a href="/hackbook/03-36-substitutes/">03-36 Substitutes</a></li>
|
||||||
<li><a href="/hackbook/03-10-boredom/">03-10 Boredom</a></li>
|
<li><time datetime="2022-12-24T09:10:40+02:00">2022 Dec 24</time> – <a href="/hackbook/03-37-should-i-avoid-temptation-situations/">03-37 Should I Avoid Temptation Situations?</a></li>
|
||||||
<li><a href="/hackbook/03-09-stress/">03-09 Stress</a></li>
|
<li><time datetime="2022-12-24T09:13:13+02:00">2022 Dec 24</time> – <a href="/hackbook/03-38-the-moment-of-revelation/">03-38 The Moment of Revelation</a></li>
|
||||||
<li><a href="/hackbook/03-08-relieving-withdrawal-pangs/">03-08 Relieving Withdrawal Pangs</a></li>
|
<li><time datetime="2022-12-24T09:15:27+02:00">2022 Dec 24</time> – <a href="/hackbook/03-39-the-final-visit/">03-39 The Final Visit</a></li>
|
||||||
<li><a href="/hackbook/03-07-brainwashing-and-the-primitive-mechanism/">03-07 Brainwashing and the Primitive Mechanism</a></li>
|
<li><time datetime="2022-12-24T09:20:54+02:00">2022 Dec 24</time> – <a href="/hackbook/03-40-a-final-warning/">03-40 A Final Warning</a></li>
|
||||||
<li><a href="/hackbook/03-06-internet-porn/">03-06 Internet Porn</a></li>
|
<li><time datetime="2022-12-24T09:21:34+02:00">2022 Dec 24</time> – <a href="/hackbook/03-41-feedback/">03-41 Feedback</a></li>
|
||||||
<li><a href="/hackbook/03-05-why-do-we-carry-on-with-pmo/">03-05 Why Do We Carry on With PMO</a></li>
|
<li><time datetime="2022-12-24T11:28:29+02:00">2022 Dec 24</time> – <a href="/hackbook/03-42-help-the-pmoer-left-on-the-sinking-ship/">03-42 Help the PMOer Left on the Sinking Ship</a></li>
|
||||||
<li><a href="/hackbook/03-04-the-sinister-trap/">03-04 The Sinister Trap</a></li>
|
<li><time datetime="2022-12-24T11:31:13+02:00">2022 Dec 24</time> – <a href="/hackbook/03-43-advice-to-non-pmoers/">03-43 Advice to Non-PMOers</a></li>
|
||||||
<li><a href="/hackbook/03-03-why-is-it-difficult-to-stop/">03-03 Why Is It Difficult to Stop?</a></li>
|
<li><time datetime="2022-12-24T11:36:58+02:00">2022 Dec 24</time> – <a href="/hackbook/03-44-should-i-tell-my-so/">03-44 Should I Tell My SO</a></li>
|
||||||
<li><a href="/hackbook/03-02-the-easy-method/">03-02 the Easy Method</a></li>
|
<li><time datetime="2022-12-24T12:13:26+02:00">2022 Dec 24</time> – <a href="/hackbook/04-01-the-instructions/">04-01 The Instructions</a></li>
|
||||||
<li><a href="/hackbook/03-01-the-worst-pmo-addict-i-have-yet-to-meet/">03-01 the Worst PMO Addict I Have Yet to Meet</a></li>
|
<li><time datetime="2022-12-24T12:14:53+02:00">2022 Dec 24</time> – <a href="/hackbook/04-02-rebt-coping-statements/">04-02 REBT_Coping_Statements</a></li>
|
||||||
<li><a href="/hackbook/02-02-sister-kenny/">02-02 Sister Kenny</a></li>
|
<li><time datetime="2022-12-24T12:17:25+02:00">2022 Dec 24</time> – <a href="/hackbook/05-01-scripts-01/">05-01 Scripts-01</a></li>
|
||||||
<li><a href="/hackbook/02-01-introduction/">02-01 Introduction</a></li>
|
<li><time datetime="2022-12-24T12:18:50+02:00">2022 Dec 24</time> – <a href="/hackbook/05-01-scripts-02/">05-01 Scripts-02</a></li>
|
||||||
<li><a href="/hackbook/01-03-fear/">01-03 Fear</a></li>
|
<li><time datetime="2022-12-24T12:20:17+02:00">2022 Dec 24</time> – <a href="/hackbook/05-01-scripts-03/">05-01 Scripts-03</a></li>
|
||||||
<li><a href="/hackbook/01-02-warning/">01-02 Warning</a></li>
|
<li><time datetime="2022-12-24T12:21:45+02:00">2022 Dec 24</time> – <a href="/hackbook/05-01-scripts-04/">05-01 Scripts-04</a></li>
|
||||||
<li><a href="/hackbook/01-01-preface/">01-01 Preface</a></li>
|
<li><time datetime="2022-12-24T12:22:57+02:00">2022 Dec 24</time> – <a href="/hackbook/05-01-scripts-05/">05-01 Scripts-05</a></li>
|
||||||
<li><a href="/hackbook/00-00-hackbookeasypeasy/">00-00 HackBook EasyPeasy</a></li>
|
<li><time datetime="2022-12-24T12:23:54+02:00">2022 Dec 24</time> – <a href="/hackbook/fin/">Fin</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
|
@ -2,14 +2,126 @@
|
||||||
<channel>
|
<channel>
|
||||||
<title>vodoraslo</title>
|
<title>vodoraslo</title>
|
||||||
<link>https://vodoraslo.xyz/hackbook/</link>
|
<link>https://vodoraslo.xyz/hackbook/</link>
|
||||||
<description>Recent content in Hackbook on vodoraslo</description>
|
<description>Recent content in Hackbook EasyPeasy on vodoraslo</description>
|
||||||
<generator>Hugo -- gohugo.io</generator>
|
<generator>Hugo -- gohugo.io</generator>
|
||||||
<language>en-us</language>
|
<language>en-us</language>
|
||||||
<lastBuildDate>Sat, 24 Dec 2022 12:23:54 +0200</lastBuildDate>
|
<lastBuildDate>Tue, 03 Jan 2023 22:32:11 +0200</lastBuildDate>
|
||||||
|
|
||||||
<atom:link href="https://vodoraslo.xyz/hackbook/index.xml" rel="self" type="application/rss+xml" />
|
<atom:link href="https://vodoraslo.xyz/hackbook/index.xml" rel="self" type="application/rss+xml" />
|
||||||
|
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<title>Multiple Index Pages in Hugo</title>
|
||||||
|
<link>https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/</link>
|
||||||
|
<pubDate>Tue, 03 Jan 2023 22:36:03 +0200</pubDate>
|
||||||
|
|
||||||
|
<guid>https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/</guid>
|
||||||
|
<description><div style="text-align: center;">
|
||||||
|
<h2 id="this-is-how-to-create-multiple-index-pages-in-hugo">This is how to create multiple index pages in Hugo</h2>
|
||||||
|
</div>
|
||||||
|
<p>I wanted to order <a href="https://vodoraslo.xyz/hackbook">Hackbook</a> in reverse (i.e. oldest to newest) so that it&rsquo;s easier for the reader to start at the correct page.</p>
|
||||||
|
<p>I ran into the following problem - the default <strong><code>list.html</code></strong> does them from newest to oldest.</p>
|
||||||
|
<p>So I found <a href="https://discourse.gohugo.io/t/two-home-pages/31312/9">this forum post</a> and I created a file in the <strong><code>_default</code></strong> directory as follows:</p>
|
||||||
|
<pre tabindex="0"><code>layouts
|
||||||
|
|----**_default**
|
||||||
|
|-------**hackbook**
|
||||||
|
|-----------**order-by-oldest.html**
|
||||||
|
|-------baseof.html
|
||||||
|
|-------index.html
|
||||||
|
|-------list.html
|
||||||
|
|-------single.html
|
||||||
|
</code></pre>
|
||||||
|
<figure ><img src="https://vodoraslo.xyz/img/custom-index-directory.PNG" alt="Picture of the directory"></figure>
|
||||||
|
|
||||||
|
<p>I named my file order by oldest because I plan on reusing it in other places. This is what&rsquo;s contained inside it:</p>
|
||||||
|
<pre tabindex="0"><code>{{ define &#34;title&#34; -}}
|
||||||
|
{{ .Title | title }}
|
||||||
|
{{- end }}
|
||||||
|
{{ define &#34;main&#34; -}}
|
||||||
|
{{ .Content }}
|
||||||
|
&lt;ul&gt;
|
||||||
|
{{- range.Pages.Reverse }}
|
||||||
|
&lt;li&gt;
|
||||||
|
{{- if .Param &#34;datesinlist&#34; }}&lt;time datetime=&#34;{{ .Date.Format &#34;2006-01-02T15:04:05Z07:00&#34; }}&#34;&gt;{{ .Date.Format &#34;2006 Jan 02&#34; }}&lt;/time&gt; &amp;ndash; {{ end -}}
|
||||||
|
&lt;a href=&#34;{{ .RelPermalink }}&#34;&gt;{{ .Title }}&lt;/a&gt;
|
||||||
|
{{- if .Param &#34;authorsinlist&#34; }}
|
||||||
|
{{- range .Param &#34;authors&#34; }} by {{ . }}{{ end -}}
|
||||||
|
{{ end -}}
|
||||||
|
&lt;/li&gt;
|
||||||
|
{{- end }}
|
||||||
|
&lt;/ul&gt;
|
||||||
|
{{- end }}
|
||||||
|
</code></pre><h4 id="if-you-want-to-display-the-date-on-the-left-of-the-titles-you-have-to-add-datesinlisttrue-in-your-configtoml-or-datesinlist-true-in-your-configyaml">if you want to display the date on the left of the titles, you have to add <strong><code>datesinlist=true</code></strong> in your config.toml or <strong><code>datesinlist: true</code></strong> in your config.yaml</h4>
|
||||||
|
<h5 id="you-probably-dont-need-enablegitinfo--true-as-that-will-crash-your-website-i-have-no-idea-what-it-does-you-dont-need-it">You probably don&rsquo;t need <strong><code>enableGitInfo = true</code></strong> as that will crash your website, I have no idea what it does, you don&rsquo;t need it.</h5>
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<h2 id="using-your-custom-_indexhtml">Using your custom _index.html</h2>
|
||||||
|
</div>
|
||||||
|
<p>After creating your custom _index.html you&rsquo;d use it as follows:</p>
|
||||||
|
<ol>
|
||||||
|
<li>Create an _index.md file in your desired directory</li>
|
||||||
|
<li>Add <strong><code>layout: &quot;hackbook/order-by-oldest&quot;</code></strong> to your preamble (if you named your folder and or file something else, you have to change it here)</li>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
<figure ><img src="https://vodoraslo.xyz/img/layout-custom-index.PNG" alt="Picture of the layout in the preamble"></figure>
|
||||||
|
|
||||||
|
<p>And now you should have a custom _index.html for your pages! :)</p>
|
||||||
|
<p>Here is a verbose copy paste of the original hugo forum answer in case it gets deleted:</p>
|
||||||
|
<pre tabindex="0"><code>Content structure:
|
||||||
|
|
||||||
|
content
|
||||||
|
├── better
|
||||||
|
│ └── _index.md
|
||||||
|
├── post
|
||||||
|
│ ├── post-1.md
|
||||||
|
│ ├── post-2.md
|
||||||
|
│ └── post-3.md
|
||||||
|
└── _index.md
|
||||||
|
|
||||||
|
content/better/_index.md
|
||||||
|
|
||||||
|
+++
|
||||||
|
title = &#34;Better&#34;
|
||||||
|
date = 2021-03-04T17:02:42-08:00
|
||||||
|
draft = false
|
||||||
|
type = &#34;post&#34;
|
||||||
|
layout = &#34;posts-by-lastmod&#34;
|
||||||
|
+++
|
||||||
|
|
||||||
|
Template structure:
|
||||||
|
|
||||||
|
layouts
|
||||||
|
├── _default
|
||||||
|
│ ├── baseof.html
|
||||||
|
│ ├── list.html
|
||||||
|
│ └── single.html
|
||||||
|
├── post
|
||||||
|
│ └── posts-by-lastmod.html
|
||||||
|
└── index.html
|
||||||
|
|
||||||
|
layouts/post/posts-by-lastmod.html
|
||||||
|
|
||||||
|
{{ define &#34;main&#34; }}
|
||||||
|
{{ .Content }}
|
||||||
|
{{ range (where .Site.RegularPages &#34;Type&#34; &#34;post&#34;).ByLastmod.Reverse }}
|
||||||
|
&lt;h2&gt;&lt;a href=&#34;{{ .RelPermalink }}&#34;&gt;{{ .Title }}&lt;/a&gt;&lt;/h2&gt;
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
layouts/index.html
|
||||||
|
|
||||||
|
{{ define &#34;main&#34; }}
|
||||||
|
{{ .Content }}
|
||||||
|
{{ range (where .Site.RegularPages &#34;Type&#34; &#34;post&#34;).ByDate.Reverse }}
|
||||||
|
&lt;h2&gt;&lt;a href=&#34;{{ .RelPermalink }}&#34;&gt;{{ .Title }}&lt;/a&gt;&lt;/h2&gt;
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
config.toml (see https://gohugo.io/variables/git/#lastmod)
|
||||||
|
|
||||||
|
enableGitInfo = true
|
||||||
|
</code></pre></description>
|
||||||
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<title>Yoinked some Css and updated the site</title>
|
<title>Yoinked some Css and updated the site</title>
|
||||||
<link>https://vodoraslo.xyz/blog/yoinked-css/</link>
|
<link>https://vodoraslo.xyz/blog/yoinked-css/</link>
|
||||||
|
|
BIN
new-site/public/img/custom-index-directory.PNG
Normal file
BIN
new-site/public/img/custom-index-directory.PNG
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
BIN
new-site/public/img/layout-custom-index.PNG
Normal file
BIN
new-site/public/img/layout-custom-index.PNG
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
|
@ -24,7 +24,7 @@
|
||||||
<h3 id="updatestagsupdates"><a href="/tags/updates">Updates</a></h3>
|
<h3 id="updatestagsupdates"><a href="/tags/updates">Updates</a></h3>
|
||||||
<h3 id="blogtagsblog"><a href="/tags/blog">Blog</a></h3>
|
<h3 id="blogtagsblog"><a href="/tags/blog">Blog</a></h3>
|
||||||
<h3 id="hackbook-easypeasyhackbook"><a href="/hackbook">Hackbook EasyPeasy</a></h3>
|
<h3 id="hackbook-easypeasyhackbook"><a href="/hackbook">Hackbook EasyPeasy</a></h3>
|
||||||
<figure ><img src="/img/wip.gif"></figure>
|
<figure ><img src="/img/wip.gif" alt="Work in progress"></figure>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,123 @@
|
||||||
<description>Recent content on vodoraslo</description>
|
<description>Recent content on vodoraslo</description>
|
||||||
<generator>Hugo -- gohugo.io</generator>
|
<generator>Hugo -- gohugo.io</generator>
|
||||||
<language>en-us</language>
|
<language>en-us</language>
|
||||||
<lastBuildDate>Tue, 27 Dec 2022 14:24:24 +0200</lastBuildDate>
|
<lastBuildDate>Tue, 03 Jan 2023 22:36:03 +0200</lastBuildDate>
|
||||||
|
|
||||||
<atom:link href="https://vodoraslo.xyz/index.xml" rel="self" type="application/rss+xml" />
|
<atom:link href="https://vodoraslo.xyz/index.xml" rel="self" type="application/rss+xml" />
|
||||||
|
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<title>Multiple Index Pages in Hugo</title>
|
||||||
|
<link>https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/</link>
|
||||||
|
<pubDate>Tue, 03 Jan 2023 22:36:03 +0200</pubDate>
|
||||||
|
|
||||||
|
<guid>https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/</guid>
|
||||||
|
<description><div style="text-align: center;">
|
||||||
|
<h2 id="this-is-how-to-create-multiple-index-pages-in-hugo">This is how to create multiple index pages in Hugo</h2>
|
||||||
|
</div>
|
||||||
|
<p>I wanted to order <a href="https://vodoraslo.xyz/hackbook">Hackbook</a> in reverse (i.e. oldest to newest) so that it&rsquo;s easier for the reader to start at the correct page.</p>
|
||||||
|
<p>I ran into the following problem - the default <strong><code>list.html</code></strong> does them from newest to oldest.</p>
|
||||||
|
<p>So I found <a href="https://discourse.gohugo.io/t/two-home-pages/31312/9">this forum post</a> and I created a file in the <strong><code>_default</code></strong> directory as follows:</p>
|
||||||
|
<pre tabindex="0"><code>layouts
|
||||||
|
|----**_default**
|
||||||
|
|-------**hackbook**
|
||||||
|
|-----------**order-by-oldest.html**
|
||||||
|
|-------baseof.html
|
||||||
|
|-------index.html
|
||||||
|
|-------list.html
|
||||||
|
|-------single.html
|
||||||
|
</code></pre>
|
||||||
|
<figure ><img src="https://vodoraslo.xyz/img/custom-index-directory.PNG" alt="Picture of the directory"></figure>
|
||||||
|
|
||||||
|
<p>I named my file order by oldest because I plan on reusing it in other places. This is what&rsquo;s contained inside it:</p>
|
||||||
|
<pre tabindex="0"><code>{{ define &#34;title&#34; -}}
|
||||||
|
{{ .Title | title }}
|
||||||
|
{{- end }}
|
||||||
|
{{ define &#34;main&#34; -}}
|
||||||
|
{{ .Content }}
|
||||||
|
&lt;ul&gt;
|
||||||
|
{{- range.Pages.Reverse }}
|
||||||
|
&lt;li&gt;
|
||||||
|
{{- if .Param &#34;datesinlist&#34; }}&lt;time datetime=&#34;{{ .Date.Format &#34;2006-01-02T15:04:05Z07:00&#34; }}&#34;&gt;{{ .Date.Format &#34;2006 Jan 02&#34; }}&lt;/time&gt; &amp;ndash; {{ end -}}
|
||||||
|
&lt;a href=&#34;{{ .RelPermalink }}&#34;&gt;{{ .Title }}&lt;/a&gt;
|
||||||
|
{{- if .Param &#34;authorsinlist&#34; }}
|
||||||
|
{{- range .Param &#34;authors&#34; }} by {{ . }}{{ end -}}
|
||||||
|
{{ end -}}
|
||||||
|
&lt;/li&gt;
|
||||||
|
{{- end }}
|
||||||
|
&lt;/ul&gt;
|
||||||
|
{{- end }}
|
||||||
|
</code></pre><h4 id="if-you-want-to-display-the-date-on-the-left-of-the-titles-you-have-to-add-datesinlisttrue-in-your-configtoml-or-datesinlist-true-in-your-configyaml">if you want to display the date on the left of the titles, you have to add <strong><code>datesinlist=true</code></strong> in your config.toml or <strong><code>datesinlist: true</code></strong> in your config.yaml</h4>
|
||||||
|
<h5 id="you-probably-dont-need-enablegitinfo--true-as-that-will-crash-your-website-i-have-no-idea-what-it-does-you-dont-need-it">You probably don&rsquo;t need <strong><code>enableGitInfo = true</code></strong> as that will crash your website, I have no idea what it does, you don&rsquo;t need it.</h5>
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<h2 id="using-your-custom-_indexhtml">Using your custom _index.html</h2>
|
||||||
|
</div>
|
||||||
|
<p>After creating your custom _index.html you&rsquo;d use it as follows:</p>
|
||||||
|
<ol>
|
||||||
|
<li>Create an _index.md file in your desired directory</li>
|
||||||
|
<li>Add <strong><code>layout: &quot;hackbook/order-by-oldest&quot;</code></strong> to your preamble (if you named your folder and or file something else, you have to change it here)</li>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
<figure ><img src="https://vodoraslo.xyz/img/layout-custom-index.PNG" alt="Picture of the layout in the preamble"></figure>
|
||||||
|
|
||||||
|
<p>And now you should have a custom _index.html for your pages! :)</p>
|
||||||
|
<p>Here is a verbose copy paste of the original hugo forum answer in case it gets deleted:</p>
|
||||||
|
<pre tabindex="0"><code>Content structure:
|
||||||
|
|
||||||
|
content
|
||||||
|
├── better
|
||||||
|
│ └── _index.md
|
||||||
|
├── post
|
||||||
|
│ ├── post-1.md
|
||||||
|
│ ├── post-2.md
|
||||||
|
│ └── post-3.md
|
||||||
|
└── _index.md
|
||||||
|
|
||||||
|
content/better/_index.md
|
||||||
|
|
||||||
|
+++
|
||||||
|
title = &#34;Better&#34;
|
||||||
|
date = 2021-03-04T17:02:42-08:00
|
||||||
|
draft = false
|
||||||
|
type = &#34;post&#34;
|
||||||
|
layout = &#34;posts-by-lastmod&#34;
|
||||||
|
+++
|
||||||
|
|
||||||
|
Template structure:
|
||||||
|
|
||||||
|
layouts
|
||||||
|
├── _default
|
||||||
|
│ ├── baseof.html
|
||||||
|
│ ├── list.html
|
||||||
|
│ └── single.html
|
||||||
|
├── post
|
||||||
|
│ └── posts-by-lastmod.html
|
||||||
|
└── index.html
|
||||||
|
|
||||||
|
layouts/post/posts-by-lastmod.html
|
||||||
|
|
||||||
|
{{ define &#34;main&#34; }}
|
||||||
|
{{ .Content }}
|
||||||
|
{{ range (where .Site.RegularPages &#34;Type&#34; &#34;post&#34;).ByLastmod.Reverse }}
|
||||||
|
&lt;h2&gt;&lt;a href=&#34;{{ .RelPermalink }}&#34;&gt;{{ .Title }}&lt;/a&gt;&lt;/h2&gt;
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
layouts/index.html
|
||||||
|
|
||||||
|
{{ define &#34;main&#34; }}
|
||||||
|
{{ .Content }}
|
||||||
|
{{ range (where .Site.RegularPages &#34;Type&#34; &#34;post&#34;).ByDate.Reverse }}
|
||||||
|
&lt;h2&gt;&lt;a href=&#34;{{ .RelPermalink }}&#34;&gt;{{ .Title }}&lt;/a&gt;&lt;/h2&gt;
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
config.toml (see https://gohugo.io/variables/git/#lastmod)
|
||||||
|
|
||||||
|
enableGitInfo = true
|
||||||
|
</code></pre></description>
|
||||||
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<title>Yoinked some Css and updated the site</title>
|
<title>Yoinked some Css and updated the site</title>
|
||||||
<link>https://vodoraslo.xyz/blog/yoinked-css/</link>
|
<link>https://vodoraslo.xyz/blog/yoinked-css/</link>
|
||||||
|
|
|
@ -3,13 +3,22 @@
|
||||||
xmlns:xhtml="http://www.w3.org/1999/xhtml">
|
xmlns:xhtml="http://www.w3.org/1999/xhtml">
|
||||||
<url>
|
<url>
|
||||||
<loc>https://vodoraslo.xyz/</loc>
|
<loc>https://vodoraslo.xyz/</loc>
|
||||||
<lastmod>2022-12-27T14:24:24+02:00</lastmod>
|
<lastmod>2023-01-03T22:36:03+02:00</lastmod>
|
||||||
|
</url><url>
|
||||||
|
<loc>https://vodoraslo.xyz/tags/blog/</loc>
|
||||||
|
<lastmod>2023-01-03T22:36:03+02:00</lastmod>
|
||||||
</url><url>
|
</url><url>
|
||||||
<loc>https://vodoraslo.xyz/blog/</loc>
|
<loc>https://vodoraslo.xyz/blog/</loc>
|
||||||
<lastmod>2022-12-27T14:24:24+02:00</lastmod>
|
<lastmod>2023-01-03T22:36:03+02:00</lastmod>
|
||||||
|
</url><url>
|
||||||
|
<loc>https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/</loc>
|
||||||
|
<lastmod>2023-01-03T22:36:03+02:00</lastmod>
|
||||||
</url><url>
|
</url><url>
|
||||||
<loc>https://vodoraslo.xyz/tags/</loc>
|
<loc>https://vodoraslo.xyz/tags/</loc>
|
||||||
<lastmod>2022-12-27T14:24:24+02:00</lastmod>
|
<lastmod>2023-01-03T22:36:03+02:00</lastmod>
|
||||||
|
</url><url>
|
||||||
|
<loc>https://vodoraslo.xyz/hackbook/</loc>
|
||||||
|
<lastmod>2023-01-03T22:32:11+02:00</lastmod>
|
||||||
</url><url>
|
</url><url>
|
||||||
<loc>https://vodoraslo.xyz/tags/updates/</loc>
|
<loc>https://vodoraslo.xyz/tags/updates/</loc>
|
||||||
<lastmod>2022-12-27T14:24:24+02:00</lastmod>
|
<lastmod>2022-12-27T14:24:24+02:00</lastmod>
|
||||||
|
@ -19,9 +28,6 @@
|
||||||
</url><url>
|
</url><url>
|
||||||
<loc>https://vodoraslo.xyz/hackbook/fin/</loc>
|
<loc>https://vodoraslo.xyz/hackbook/fin/</loc>
|
||||||
<lastmod>2022-12-24T12:23:54+02:00</lastmod>
|
<lastmod>2022-12-24T12:23:54+02:00</lastmod>
|
||||||
</url><url>
|
|
||||||
<loc>https://vodoraslo.xyz/hackbook/</loc>
|
|
||||||
<lastmod>2022-12-24T12:23:54+02:00</lastmod>
|
|
||||||
</url><url>
|
</url><url>
|
||||||
<loc>https://vodoraslo.xyz/hackbook/05-01-scripts-05/</loc>
|
<loc>https://vodoraslo.xyz/hackbook/05-01-scripts-05/</loc>
|
||||||
<lastmod>2022-12-24T12:22:57+02:00</lastmod>
|
<lastmod>2022-12-24T12:22:57+02:00</lastmod>
|
||||||
|
@ -193,9 +199,6 @@
|
||||||
</url><url>
|
</url><url>
|
||||||
<loc>https://vodoraslo.xyz/hackbook/00-00-hackbookeasypeasy/</loc>
|
<loc>https://vodoraslo.xyz/hackbook/00-00-hackbookeasypeasy/</loc>
|
||||||
<lastmod>2022-12-19T22:01:36+02:00</lastmod>
|
<lastmod>2022-12-19T22:01:36+02:00</lastmod>
|
||||||
</url><url>
|
|
||||||
<loc>https://vodoraslo.xyz/tags/blog/</loc>
|
|
||||||
<lastmod>2022-12-17T22:33:25+02:00</lastmod>
|
|
||||||
</url><url>
|
</url><url>
|
||||||
<loc>https://vodoraslo.xyz/blog/pluralization-issues/</loc>
|
<loc>https://vodoraslo.xyz/blog/pluralization-issues/</loc>
|
||||||
<lastmod>2022-12-17T22:33:25+02:00</lastmod>
|
<lastmod>2022-12-17T22:33:25+02:00</lastmod>
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
<article>
|
<article>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="/blog/pluralization-issues/">Pluralization issues (Blogs instead of Blog)</a></li>
|
<li><time datetime="2023-01-03T22:36:03+02:00">2023 Jan 03</time> – <a href="/blog/multiple-index-pages-in-hugo/">Multiple Index Pages in Hugo</a></li>
|
||||||
|
<li><time datetime="2022-12-17T22:33:25+02:00">2022 Dec 17</time> – <a href="/blog/pluralization-issues/">Pluralization issues (Blogs instead of Blog)</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
|
@ -5,11 +5,123 @@
|
||||||
<description>Recent content in blog on vodoraslo</description>
|
<description>Recent content in blog on vodoraslo</description>
|
||||||
<generator>Hugo -- gohugo.io</generator>
|
<generator>Hugo -- gohugo.io</generator>
|
||||||
<language>en-us</language>
|
<language>en-us</language>
|
||||||
<lastBuildDate>Sat, 17 Dec 2022 22:33:25 +0200</lastBuildDate>
|
<lastBuildDate>Tue, 03 Jan 2023 22:36:03 +0200</lastBuildDate>
|
||||||
|
|
||||||
<atom:link href="https://vodoraslo.xyz/tags/blog/index.xml" rel="self" type="application/rss+xml" />
|
<atom:link href="https://vodoraslo.xyz/tags/blog/index.xml" rel="self" type="application/rss+xml" />
|
||||||
|
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<title>Multiple Index Pages in Hugo</title>
|
||||||
|
<link>https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/</link>
|
||||||
|
<pubDate>Tue, 03 Jan 2023 22:36:03 +0200</pubDate>
|
||||||
|
|
||||||
|
<guid>https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/</guid>
|
||||||
|
<description><div style="text-align: center;">
|
||||||
|
<h2 id="this-is-how-to-create-multiple-index-pages-in-hugo">This is how to create multiple index pages in Hugo</h2>
|
||||||
|
</div>
|
||||||
|
<p>I wanted to order <a href="https://vodoraslo.xyz/hackbook">Hackbook</a> in reverse (i.e. oldest to newest) so that it&rsquo;s easier for the reader to start at the correct page.</p>
|
||||||
|
<p>I ran into the following problem - the default <strong><code>list.html</code></strong> does them from newest to oldest.</p>
|
||||||
|
<p>So I found <a href="https://discourse.gohugo.io/t/two-home-pages/31312/9">this forum post</a> and I created a file in the <strong><code>_default</code></strong> directory as follows:</p>
|
||||||
|
<pre tabindex="0"><code>layouts
|
||||||
|
|----**_default**
|
||||||
|
|-------**hackbook**
|
||||||
|
|-----------**order-by-oldest.html**
|
||||||
|
|-------baseof.html
|
||||||
|
|-------index.html
|
||||||
|
|-------list.html
|
||||||
|
|-------single.html
|
||||||
|
</code></pre>
|
||||||
|
<figure ><img src="https://vodoraslo.xyz/img/custom-index-directory.PNG" alt="Picture of the directory"></figure>
|
||||||
|
|
||||||
|
<p>I named my file order by oldest because I plan on reusing it in other places. This is what&rsquo;s contained inside it:</p>
|
||||||
|
<pre tabindex="0"><code>{{ define &#34;title&#34; -}}
|
||||||
|
{{ .Title | title }}
|
||||||
|
{{- end }}
|
||||||
|
{{ define &#34;main&#34; -}}
|
||||||
|
{{ .Content }}
|
||||||
|
&lt;ul&gt;
|
||||||
|
{{- range.Pages.Reverse }}
|
||||||
|
&lt;li&gt;
|
||||||
|
{{- if .Param &#34;datesinlist&#34; }}&lt;time datetime=&#34;{{ .Date.Format &#34;2006-01-02T15:04:05Z07:00&#34; }}&#34;&gt;{{ .Date.Format &#34;2006 Jan 02&#34; }}&lt;/time&gt; &amp;ndash; {{ end -}}
|
||||||
|
&lt;a href=&#34;{{ .RelPermalink }}&#34;&gt;{{ .Title }}&lt;/a&gt;
|
||||||
|
{{- if .Param &#34;authorsinlist&#34; }}
|
||||||
|
{{- range .Param &#34;authors&#34; }} by {{ . }}{{ end -}}
|
||||||
|
{{ end -}}
|
||||||
|
&lt;/li&gt;
|
||||||
|
{{- end }}
|
||||||
|
&lt;/ul&gt;
|
||||||
|
{{- end }}
|
||||||
|
</code></pre><h4 id="if-you-want-to-display-the-date-on-the-left-of-the-titles-you-have-to-add-datesinlisttrue-in-your-configtoml-or-datesinlist-true-in-your-configyaml">if you want to display the date on the left of the titles, you have to add <strong><code>datesinlist=true</code></strong> in your config.toml or <strong><code>datesinlist: true</code></strong> in your config.yaml</h4>
|
||||||
|
<h5 id="you-probably-dont-need-enablegitinfo--true-as-that-will-crash-your-website-i-have-no-idea-what-it-does-you-dont-need-it">You probably don&rsquo;t need <strong><code>enableGitInfo = true</code></strong> as that will crash your website, I have no idea what it does, you don&rsquo;t need it.</h5>
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<h2 id="using-your-custom-_indexhtml">Using your custom _index.html</h2>
|
||||||
|
</div>
|
||||||
|
<p>After creating your custom _index.html you&rsquo;d use it as follows:</p>
|
||||||
|
<ol>
|
||||||
|
<li>Create an _index.md file in your desired directory</li>
|
||||||
|
<li>Add <strong><code>layout: &quot;hackbook/order-by-oldest&quot;</code></strong> to your preamble (if you named your folder and or file something else, you have to change it here)</li>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
<figure ><img src="https://vodoraslo.xyz/img/layout-custom-index.PNG" alt="Picture of the layout in the preamble"></figure>
|
||||||
|
|
||||||
|
<p>And now you should have a custom _index.html for your pages! :)</p>
|
||||||
|
<p>Here is a verbose copy paste of the original hugo forum answer in case it gets deleted:</p>
|
||||||
|
<pre tabindex="0"><code>Content structure:
|
||||||
|
|
||||||
|
content
|
||||||
|
├── better
|
||||||
|
│ └── _index.md
|
||||||
|
├── post
|
||||||
|
│ ├── post-1.md
|
||||||
|
│ ├── post-2.md
|
||||||
|
│ └── post-3.md
|
||||||
|
└── _index.md
|
||||||
|
|
||||||
|
content/better/_index.md
|
||||||
|
|
||||||
|
+++
|
||||||
|
title = &#34;Better&#34;
|
||||||
|
date = 2021-03-04T17:02:42-08:00
|
||||||
|
draft = false
|
||||||
|
type = &#34;post&#34;
|
||||||
|
layout = &#34;posts-by-lastmod&#34;
|
||||||
|
+++
|
||||||
|
|
||||||
|
Template structure:
|
||||||
|
|
||||||
|
layouts
|
||||||
|
├── _default
|
||||||
|
│ ├── baseof.html
|
||||||
|
│ ├── list.html
|
||||||
|
│ └── single.html
|
||||||
|
├── post
|
||||||
|
│ └── posts-by-lastmod.html
|
||||||
|
└── index.html
|
||||||
|
|
||||||
|
layouts/post/posts-by-lastmod.html
|
||||||
|
|
||||||
|
{{ define &#34;main&#34; }}
|
||||||
|
{{ .Content }}
|
||||||
|
{{ range (where .Site.RegularPages &#34;Type&#34; &#34;post&#34;).ByLastmod.Reverse }}
|
||||||
|
&lt;h2&gt;&lt;a href=&#34;{{ .RelPermalink }}&#34;&gt;{{ .Title }}&lt;/a&gt;&lt;/h2&gt;
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
layouts/index.html
|
||||||
|
|
||||||
|
{{ define &#34;main&#34; }}
|
||||||
|
{{ .Content }}
|
||||||
|
{{ range (where .Site.RegularPages &#34;Type&#34; &#34;post&#34;).ByDate.Reverse }}
|
||||||
|
&lt;h2&gt;&lt;a href=&#34;{{ .RelPermalink }}&#34;&gt;{{ .Title }}&lt;/a&gt;&lt;/h2&gt;
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
config.toml (see https://gohugo.io/variables/git/#lastmod)
|
||||||
|
|
||||||
|
enableGitInfo = true
|
||||||
|
</code></pre></description>
|
||||||
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<title>Yoinked some Css and updated the site</title>
|
<title>Yoinked some Css and updated the site</title>
|
||||||
<link>https://vodoraslo.xyz/blog/yoinked-css/</link>
|
<link>https://vodoraslo.xyz/blog/yoinked-css/</link>
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
<article>
|
<article>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="/tags/updates/">updates</a></li>
|
<li><time datetime="2023-01-03T22:36:03+02:00">2023 Jan 03</time> – <a href="/tags/blog/">blog</a></li>
|
||||||
<li><a href="/tags/blog/">blog</a></li>
|
<li><time datetime="2022-12-27T14:24:24+02:00">2022 Dec 27</time> – <a href="/tags/updates/">updates</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
|
@ -5,11 +5,123 @@
|
||||||
<description>Recent content in Tags on vodoraslo</description>
|
<description>Recent content in Tags on vodoraslo</description>
|
||||||
<generator>Hugo -- gohugo.io</generator>
|
<generator>Hugo -- gohugo.io</generator>
|
||||||
<language>en-us</language>
|
<language>en-us</language>
|
||||||
<lastBuildDate>Tue, 27 Dec 2022 14:24:24 +0200</lastBuildDate>
|
<lastBuildDate>Tue, 03 Jan 2023 22:36:03 +0200</lastBuildDate>
|
||||||
|
|
||||||
<atom:link href="https://vodoraslo.xyz/tags/index.xml" rel="self" type="application/rss+xml" />
|
<atom:link href="https://vodoraslo.xyz/tags/index.xml" rel="self" type="application/rss+xml" />
|
||||||
|
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<title>Multiple Index Pages in Hugo</title>
|
||||||
|
<link>https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/</link>
|
||||||
|
<pubDate>Tue, 03 Jan 2023 22:36:03 +0200</pubDate>
|
||||||
|
|
||||||
|
<guid>https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/</guid>
|
||||||
|
<description><div style="text-align: center;">
|
||||||
|
<h2 id="this-is-how-to-create-multiple-index-pages-in-hugo">This is how to create multiple index pages in Hugo</h2>
|
||||||
|
</div>
|
||||||
|
<p>I wanted to order <a href="https://vodoraslo.xyz/hackbook">Hackbook</a> in reverse (i.e. oldest to newest) so that it&rsquo;s easier for the reader to start at the correct page.</p>
|
||||||
|
<p>I ran into the following problem - the default <strong><code>list.html</code></strong> does them from newest to oldest.</p>
|
||||||
|
<p>So I found <a href="https://discourse.gohugo.io/t/two-home-pages/31312/9">this forum post</a> and I created a file in the <strong><code>_default</code></strong> directory as follows:</p>
|
||||||
|
<pre tabindex="0"><code>layouts
|
||||||
|
|----**_default**
|
||||||
|
|-------**hackbook**
|
||||||
|
|-----------**order-by-oldest.html**
|
||||||
|
|-------baseof.html
|
||||||
|
|-------index.html
|
||||||
|
|-------list.html
|
||||||
|
|-------single.html
|
||||||
|
</code></pre>
|
||||||
|
<figure ><img src="https://vodoraslo.xyz/img/custom-index-directory.PNG" alt="Picture of the directory"></figure>
|
||||||
|
|
||||||
|
<p>I named my file order by oldest because I plan on reusing it in other places. This is what&rsquo;s contained inside it:</p>
|
||||||
|
<pre tabindex="0"><code>{{ define &#34;title&#34; -}}
|
||||||
|
{{ .Title | title }}
|
||||||
|
{{- end }}
|
||||||
|
{{ define &#34;main&#34; -}}
|
||||||
|
{{ .Content }}
|
||||||
|
&lt;ul&gt;
|
||||||
|
{{- range.Pages.Reverse }}
|
||||||
|
&lt;li&gt;
|
||||||
|
{{- if .Param &#34;datesinlist&#34; }}&lt;time datetime=&#34;{{ .Date.Format &#34;2006-01-02T15:04:05Z07:00&#34; }}&#34;&gt;{{ .Date.Format &#34;2006 Jan 02&#34; }}&lt;/time&gt; &amp;ndash; {{ end -}}
|
||||||
|
&lt;a href=&#34;{{ .RelPermalink }}&#34;&gt;{{ .Title }}&lt;/a&gt;
|
||||||
|
{{- if .Param &#34;authorsinlist&#34; }}
|
||||||
|
{{- range .Param &#34;authors&#34; }} by {{ . }}{{ end -}}
|
||||||
|
{{ end -}}
|
||||||
|
&lt;/li&gt;
|
||||||
|
{{- end }}
|
||||||
|
&lt;/ul&gt;
|
||||||
|
{{- end }}
|
||||||
|
</code></pre><h4 id="if-you-want-to-display-the-date-on-the-left-of-the-titles-you-have-to-add-datesinlisttrue-in-your-configtoml-or-datesinlist-true-in-your-configyaml">if you want to display the date on the left of the titles, you have to add <strong><code>datesinlist=true</code></strong> in your config.toml or <strong><code>datesinlist: true</code></strong> in your config.yaml</h4>
|
||||||
|
<h5 id="you-probably-dont-need-enablegitinfo--true-as-that-will-crash-your-website-i-have-no-idea-what-it-does-you-dont-need-it">You probably don&rsquo;t need <strong><code>enableGitInfo = true</code></strong> as that will crash your website, I have no idea what it does, you don&rsquo;t need it.</h5>
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<h2 id="using-your-custom-_indexhtml">Using your custom _index.html</h2>
|
||||||
|
</div>
|
||||||
|
<p>After creating your custom _index.html you&rsquo;d use it as follows:</p>
|
||||||
|
<ol>
|
||||||
|
<li>Create an _index.md file in your desired directory</li>
|
||||||
|
<li>Add <strong><code>layout: &quot;hackbook/order-by-oldest&quot;</code></strong> to your preamble (if you named your folder and or file something else, you have to change it here)</li>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
<figure ><img src="https://vodoraslo.xyz/img/layout-custom-index.PNG" alt="Picture of the layout in the preamble"></figure>
|
||||||
|
|
||||||
|
<p>And now you should have a custom _index.html for your pages! :)</p>
|
||||||
|
<p>Here is a verbose copy paste of the original hugo forum answer in case it gets deleted:</p>
|
||||||
|
<pre tabindex="0"><code>Content structure:
|
||||||
|
|
||||||
|
content
|
||||||
|
├── better
|
||||||
|
│ └── _index.md
|
||||||
|
├── post
|
||||||
|
│ ├── post-1.md
|
||||||
|
│ ├── post-2.md
|
||||||
|
│ └── post-3.md
|
||||||
|
└── _index.md
|
||||||
|
|
||||||
|
content/better/_index.md
|
||||||
|
|
||||||
|
+++
|
||||||
|
title = &#34;Better&#34;
|
||||||
|
date = 2021-03-04T17:02:42-08:00
|
||||||
|
draft = false
|
||||||
|
type = &#34;post&#34;
|
||||||
|
layout = &#34;posts-by-lastmod&#34;
|
||||||
|
+++
|
||||||
|
|
||||||
|
Template structure:
|
||||||
|
|
||||||
|
layouts
|
||||||
|
├── _default
|
||||||
|
│ ├── baseof.html
|
||||||
|
│ ├── list.html
|
||||||
|
│ └── single.html
|
||||||
|
├── post
|
||||||
|
│ └── posts-by-lastmod.html
|
||||||
|
└── index.html
|
||||||
|
|
||||||
|
layouts/post/posts-by-lastmod.html
|
||||||
|
|
||||||
|
{{ define &#34;main&#34; }}
|
||||||
|
{{ .Content }}
|
||||||
|
{{ range (where .Site.RegularPages &#34;Type&#34; &#34;post&#34;).ByLastmod.Reverse }}
|
||||||
|
&lt;h2&gt;&lt;a href=&#34;{{ .RelPermalink }}&#34;&gt;{{ .Title }}&lt;/a&gt;&lt;/h2&gt;
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
layouts/index.html
|
||||||
|
|
||||||
|
{{ define &#34;main&#34; }}
|
||||||
|
{{ .Content }}
|
||||||
|
{{ range (where .Site.RegularPages &#34;Type&#34; &#34;post&#34;).ByDate.Reverse }}
|
||||||
|
&lt;h2&gt;&lt;a href=&#34;{{ .RelPermalink }}&#34;&gt;{{ .Title }}&lt;/a&gt;&lt;/h2&gt;
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
config.toml (see https://gohugo.io/variables/git/#lastmod)
|
||||||
|
|
||||||
|
enableGitInfo = true
|
||||||
|
</code></pre></description>
|
||||||
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<title>Yoinked some Css and updated the site</title>
|
<title>Yoinked some Css and updated the site</title>
|
||||||
<link>https://vodoraslo.xyz/blog/yoinked-css/</link>
|
<link>https://vodoraslo.xyz/blog/yoinked-css/</link>
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
<article>
|
<article>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="/blog/yoinked-css/">Yoinked some Css and updated the site</a></li>
|
<li><time datetime="2022-12-27T14:24:24+02:00">2022 Dec 27</time> – <a href="/blog/yoinked-css/">Yoinked some Css and updated the site</a></li>
|
||||||
<li><a href="/helloworld/">Hello world</a></li>
|
<li><time datetime="2022-12-17T17:20:18+02:00">2022 Dec 17</time> – <a href="/helloworld/">Hello world</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
|
@ -10,6 +10,118 @@
|
||||||
<atom:link href="https://vodoraslo.xyz/tags/updates/index.xml" rel="self" type="application/rss+xml" />
|
<atom:link href="https://vodoraslo.xyz/tags/updates/index.xml" rel="self" type="application/rss+xml" />
|
||||||
|
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<title>Multiple Index Pages in Hugo</title>
|
||||||
|
<link>https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/</link>
|
||||||
|
<pubDate>Tue, 03 Jan 2023 22:36:03 +0200</pubDate>
|
||||||
|
|
||||||
|
<guid>https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/</guid>
|
||||||
|
<description><div style="text-align: center;">
|
||||||
|
<h2 id="this-is-how-to-create-multiple-index-pages-in-hugo">This is how to create multiple index pages in Hugo</h2>
|
||||||
|
</div>
|
||||||
|
<p>I wanted to order <a href="https://vodoraslo.xyz/hackbook">Hackbook</a> in reverse (i.e. oldest to newest) so that it&rsquo;s easier for the reader to start at the correct page.</p>
|
||||||
|
<p>I ran into the following problem - the default <strong><code>list.html</code></strong> does them from newest to oldest.</p>
|
||||||
|
<p>So I found <a href="https://discourse.gohugo.io/t/two-home-pages/31312/9">this forum post</a> and I created a file in the <strong><code>_default</code></strong> directory as follows:</p>
|
||||||
|
<pre tabindex="0"><code>layouts
|
||||||
|
|----**_default**
|
||||||
|
|-------**hackbook**
|
||||||
|
|-----------**order-by-oldest.html**
|
||||||
|
|-------baseof.html
|
||||||
|
|-------index.html
|
||||||
|
|-------list.html
|
||||||
|
|-------single.html
|
||||||
|
</code></pre>
|
||||||
|
<figure ><img src="https://vodoraslo.xyz/img/custom-index-directory.PNG" alt="Picture of the directory"></figure>
|
||||||
|
|
||||||
|
<p>I named my file order by oldest because I plan on reusing it in other places. This is what&rsquo;s contained inside it:</p>
|
||||||
|
<pre tabindex="0"><code>{{ define &#34;title&#34; -}}
|
||||||
|
{{ .Title | title }}
|
||||||
|
{{- end }}
|
||||||
|
{{ define &#34;main&#34; -}}
|
||||||
|
{{ .Content }}
|
||||||
|
&lt;ul&gt;
|
||||||
|
{{- range.Pages.Reverse }}
|
||||||
|
&lt;li&gt;
|
||||||
|
{{- if .Param &#34;datesinlist&#34; }}&lt;time datetime=&#34;{{ .Date.Format &#34;2006-01-02T15:04:05Z07:00&#34; }}&#34;&gt;{{ .Date.Format &#34;2006 Jan 02&#34; }}&lt;/time&gt; &amp;ndash; {{ end -}}
|
||||||
|
&lt;a href=&#34;{{ .RelPermalink }}&#34;&gt;{{ .Title }}&lt;/a&gt;
|
||||||
|
{{- if .Param &#34;authorsinlist&#34; }}
|
||||||
|
{{- range .Param &#34;authors&#34; }} by {{ . }}{{ end -}}
|
||||||
|
{{ end -}}
|
||||||
|
&lt;/li&gt;
|
||||||
|
{{- end }}
|
||||||
|
&lt;/ul&gt;
|
||||||
|
{{- end }}
|
||||||
|
</code></pre><h4 id="if-you-want-to-display-the-date-on-the-left-of-the-titles-you-have-to-add-datesinlisttrue-in-your-configtoml-or-datesinlist-true-in-your-configyaml">if you want to display the date on the left of the titles, you have to add <strong><code>datesinlist=true</code></strong> in your config.toml or <strong><code>datesinlist: true</code></strong> in your config.yaml</h4>
|
||||||
|
<h5 id="you-probably-dont-need-enablegitinfo--true-as-that-will-crash-your-website-i-have-no-idea-what-it-does-you-dont-need-it">You probably don&rsquo;t need <strong><code>enableGitInfo = true</code></strong> as that will crash your website, I have no idea what it does, you don&rsquo;t need it.</h5>
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<h2 id="using-your-custom-_indexhtml">Using your custom _index.html</h2>
|
||||||
|
</div>
|
||||||
|
<p>After creating your custom _index.html you&rsquo;d use it as follows:</p>
|
||||||
|
<ol>
|
||||||
|
<li>Create an _index.md file in your desired directory</li>
|
||||||
|
<li>Add <strong><code>layout: &quot;hackbook/order-by-oldest&quot;</code></strong> to your preamble (if you named your folder and or file something else, you have to change it here)</li>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
<figure ><img src="https://vodoraslo.xyz/img/layout-custom-index.PNG" alt="Picture of the layout in the preamble"></figure>
|
||||||
|
|
||||||
|
<p>And now you should have a custom _index.html for your pages! :)</p>
|
||||||
|
<p>Here is a verbose copy paste of the original hugo forum answer in case it gets deleted:</p>
|
||||||
|
<pre tabindex="0"><code>Content structure:
|
||||||
|
|
||||||
|
content
|
||||||
|
├── better
|
||||||
|
│ └── _index.md
|
||||||
|
├── post
|
||||||
|
│ ├── post-1.md
|
||||||
|
│ ├── post-2.md
|
||||||
|
│ └── post-3.md
|
||||||
|
└── _index.md
|
||||||
|
|
||||||
|
content/better/_index.md
|
||||||
|
|
||||||
|
+++
|
||||||
|
title = &#34;Better&#34;
|
||||||
|
date = 2021-03-04T17:02:42-08:00
|
||||||
|
draft = false
|
||||||
|
type = &#34;post&#34;
|
||||||
|
layout = &#34;posts-by-lastmod&#34;
|
||||||
|
+++
|
||||||
|
|
||||||
|
Template structure:
|
||||||
|
|
||||||
|
layouts
|
||||||
|
├── _default
|
||||||
|
│ ├── baseof.html
|
||||||
|
│ ├── list.html
|
||||||
|
│ └── single.html
|
||||||
|
├── post
|
||||||
|
│ └── posts-by-lastmod.html
|
||||||
|
└── index.html
|
||||||
|
|
||||||
|
layouts/post/posts-by-lastmod.html
|
||||||
|
|
||||||
|
{{ define &#34;main&#34; }}
|
||||||
|
{{ .Content }}
|
||||||
|
{{ range (where .Site.RegularPages &#34;Type&#34; &#34;post&#34;).ByLastmod.Reverse }}
|
||||||
|
&lt;h2&gt;&lt;a href=&#34;{{ .RelPermalink }}&#34;&gt;{{ .Title }}&lt;/a&gt;&lt;/h2&gt;
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
layouts/index.html
|
||||||
|
|
||||||
|
{{ define &#34;main&#34; }}
|
||||||
|
{{ .Content }}
|
||||||
|
{{ range (where .Site.RegularPages &#34;Type&#34; &#34;post&#34;).ByDate.Reverse }}
|
||||||
|
&lt;h2&gt;&lt;a href=&#34;{{ .RelPermalink }}&#34;&gt;{{ .Title }}&lt;/a&gt;&lt;/h2&gt;
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
config.toml (see https://gohugo.io/variables/git/#lastmod)
|
||||||
|
|
||||||
|
enableGitInfo = true
|
||||||
|
</code></pre></description>
|
||||||
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<title>Yoinked some Css and updated the site</title>
|
<title>Yoinked some Css and updated the site</title>
|
||||||
<link>https://vodoraslo.xyz/blog/yoinked-css/</link>
|
<link>https://vodoraslo.xyz/blog/yoinked-css/</link>
|
||||||
|
|
BIN
new-site/static/img/custom-index-directory.PNG
Normal file
BIN
new-site/static/img/custom-index-directory.PNG
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
BIN
new-site/static/img/layout-custom-index.PNG
Normal file
BIN
new-site/static/img/layout-custom-index.PNG
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
|
@ -0,0 +1,17 @@
|
||||||
|
{{ define "title" -}}
|
||||||
|
{{ .Title | title }}
|
||||||
|
{{- end }}
|
||||||
|
{{ define "main" -}}
|
||||||
|
{{ .Content }}
|
||||||
|
<ul>
|
||||||
|
{{- range.Pages.Reverse }}
|
||||||
|
<li>
|
||||||
|
{{- if .Param "datesinlist" }}<time datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Date.Format "2006 Jan 02" }}</time> – {{ end -}}
|
||||||
|
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
|
||||||
|
{{- if .Param "authorsinlist" }}
|
||||||
|
{{- range .Param "authors" }} by {{ . }}{{ end -}}
|
||||||
|
{{ end -}}
|
||||||
|
</li>
|
||||||
|
{{- end }}
|
||||||
|
</ul>
|
||||||
|
{{- end }}
|
Loading…
Reference in a new issue