diff --git a/new-site/config.toml b/new-site/config.toml index 92a74fb1..de5450f7 100644 --- a/new-site/config.toml +++ b/new-site/config.toml @@ -8,6 +8,7 @@ pluralizelisttitles = false showrss = true nextprev = true taglist = true +datesinlist = true [markup] [markup.goldmark] diff --git a/new-site/content/_index.md b/new-site/content/_index.md index 1cce95b2..e2e8da45 100644 --- a/new-site/content/_index.md +++ b/new-site/content/_index.md @@ -11,6 +11,6 @@ ### [Hackbook EasyPeasy](/hackbook) -{{< img src=/img/wip.gif >}} +{{< img src=/img/wip.gif alt="Work in progress">}} {{% /center %}} \ No newline at end of file diff --git a/new-site/content/blog/multiple-index-pages-in-hugo.md b/new-site/content/blog/multiple-index-pages-in-hugo.md new file mode 100644 index 00000000..8e6e2e9d --- /dev/null +++ b/new-site/content/blog/multiple-index-pages-in-hugo.md @@ -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 }} + +{{- 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 }} +

{{ .Title }}

+ {{ end }} +{{ end }} + +layouts/index.html + +{{ define "main" }} + {{ .Content }} + {{ range (where .Site.RegularPages "Type" "post").ByDate.Reverse }} +

{{ .Title }}

+ {{ end }} +{{ end }} + +config.toml (see https://gohugo.io/variables/git/#lastmod) + +enableGitInfo = true + + +``` \ No newline at end of file diff --git a/new-site/content/hackbook/_index.md b/new-site/content/hackbook/_index.md new file mode 100644 index 00000000..cd19df78 --- /dev/null +++ b/new-site/content/hackbook/_index.md @@ -0,0 +1,7 @@ +--- +title: "Hackbook EasyPeasy" +date: 2023-01-03T22:32:11+02:00 +draft: false +layout: "hackbook/order-by-oldest" +--- + diff --git a/new-site/public/blog/index.html b/new-site/public/blog/index.html index 2ff9c4e2..d131982c 100644 --- a/new-site/public/blog/index.html +++ b/new-site/public/blog/index.html @@ -17,8 +17,9 @@


diff --git a/new-site/public/blog/index.xml b/new-site/public/blog/index.xml index f9ba57af..e148bbae 100644 --- a/new-site/public/blog/index.xml +++ b/new-site/public/blog/index.xml @@ -5,11 +5,123 @@ Recent content in Blog on vodoraslo Hugo -- gohugo.io en-us - Tue, 27 Dec 2022 14:24:24 +0200 + Tue, 03 Jan 2023 22:36:03 +0200 + + Multiple Index Pages in Hugo + https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/ + Tue, 03 Jan 2023 22:36:03 +0200 + + https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/ + <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> + + Yoinked some Css and updated the site https://vodoraslo.xyz/blog/yoinked-css/ diff --git a/new-site/public/blog/multiple-index-pages-in-hugo/index.html b/new-site/public/blog/multiple-index-pages-in-hugo/index.html new file mode 100644 index 00000000..60df2329 --- /dev/null +++ b/new-site/public/blog/multiple-index-pages-in-hugo/index.html @@ -0,0 +1,143 @@ + + + + Multiple Index Pages in Hugo | vodoraslo + + + + + + + + + + + +
+

Multiple Index Pages in Hugo

+
+ +
+

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.html**
+|-------baseof.html
+|-------index.html
+|-------list.html
+|-------single.html           
+
+
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> &ndash; {{ 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.
+
+

Using your custom _index.html

+
+

After creating your custom _index.html you’d use it as follows:

+
    +
  1. Create an _index.md file in your desired directory
  2. +
  3. 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)
  4. +
+ +
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
+
+ + +
+ Tags: [Blog] +
+

+
+
+ + + + + diff --git a/new-site/public/blog/yoinked-css/index.html b/new-site/public/blog/yoinked-css/index.html index 04f1d539..ee8f8931 100644 --- a/new-site/public/blog/yoinked-css/index.html +++ b/new-site/public/blog/yoinked-css/index.html @@ -22,6 +22,7 @@
Tags: [Updates] diff --git a/new-site/public/categories/index.xml b/new-site/public/categories/index.xml index eef938d9..9a65d2aa 100644 --- a/new-site/public/categories/index.xml +++ b/new-site/public/categories/index.xml @@ -9,6 +9,118 @@ + + Multiple Index Pages in Hugo + https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/ + Tue, 03 Jan 2023 22:36:03 +0200 + + https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/ + <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> + + Yoinked some Css and updated the site https://vodoraslo.xyz/blog/yoinked-css/ diff --git a/new-site/public/hackbook/index.html b/new-site/public/hackbook/index.html index 6dc2a22b..1d369fd8 100644 --- a/new-site/public/hackbook/index.html +++ b/new-site/public/hackbook/index.html @@ -1,7 +1,7 @@ - Hackbook | vodoraslo + Hackbook EasyPeasy | vodoraslo @@ -13,68 +13,68 @@
-

Hackbook

+

Hackbook EasyPeasy



diff --git a/new-site/public/hackbook/index.xml b/new-site/public/hackbook/index.xml index 5864db38..fc60f413 100644 --- a/new-site/public/hackbook/index.xml +++ b/new-site/public/hackbook/index.xml @@ -2,14 +2,126 @@ vodoraslo https://vodoraslo.xyz/hackbook/ - Recent content in Hackbook on vodoraslo + Recent content in Hackbook EasyPeasy on vodoraslo Hugo -- gohugo.io en-us - Sat, 24 Dec 2022 12:23:54 +0200 + Tue, 03 Jan 2023 22:32:11 +0200 + + Multiple Index Pages in Hugo + https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/ + Tue, 03 Jan 2023 22:36:03 +0200 + + https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/ + <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> + + Yoinked some Css and updated the site https://vodoraslo.xyz/blog/yoinked-css/ diff --git a/new-site/public/img/custom-index-directory.PNG b/new-site/public/img/custom-index-directory.PNG new file mode 100644 index 00000000..1c6ca3a0 Binary files /dev/null and b/new-site/public/img/custom-index-directory.PNG differ diff --git a/new-site/public/img/layout-custom-index.PNG b/new-site/public/img/layout-custom-index.PNG new file mode 100644 index 00000000..6517e809 Binary files /dev/null and b/new-site/public/img/layout-custom-index.PNG differ diff --git a/new-site/public/index.html b/new-site/public/index.html index 3197d4c6..5221ad57 100644 --- a/new-site/public/index.html +++ b/new-site/public/index.html @@ -24,7 +24,7 @@

Updates

Blog

Hackbook EasyPeasy

-
+
Work in progress
diff --git a/new-site/public/index.xml b/new-site/public/index.xml index e52c99d0..462b3d5b 100644 --- a/new-site/public/index.xml +++ b/new-site/public/index.xml @@ -5,11 +5,123 @@ Recent content on vodoraslo Hugo -- gohugo.io en-us - Tue, 27 Dec 2022 14:24:24 +0200 + Tue, 03 Jan 2023 22:36:03 +0200 + + Multiple Index Pages in Hugo + https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/ + Tue, 03 Jan 2023 22:36:03 +0200 + + https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/ + <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> + + Yoinked some Css and updated the site https://vodoraslo.xyz/blog/yoinked-css/ diff --git a/new-site/public/sitemap.xml b/new-site/public/sitemap.xml index 1eec20c0..3ee27382 100644 --- a/new-site/public/sitemap.xml +++ b/new-site/public/sitemap.xml @@ -3,13 +3,22 @@ xmlns:xhtml="http://www.w3.org/1999/xhtml"> https://vodoraslo.xyz/ - 2022-12-27T14:24:24+02:00 + 2023-01-03T22:36:03+02:00 + + https://vodoraslo.xyz/tags/blog/ + 2023-01-03T22:36:03+02:00 https://vodoraslo.xyz/blog/ - 2022-12-27T14:24:24+02:00 + 2023-01-03T22:36:03+02:00 + + https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/ + 2023-01-03T22:36:03+02:00 https://vodoraslo.xyz/tags/ - 2022-12-27T14:24:24+02:00 + 2023-01-03T22:36:03+02:00 + + https://vodoraslo.xyz/hackbook/ + 2023-01-03T22:32:11+02:00 https://vodoraslo.xyz/tags/updates/ 2022-12-27T14:24:24+02:00 @@ -19,9 +28,6 @@ https://vodoraslo.xyz/hackbook/fin/ 2022-12-24T12:23:54+02:00 - - https://vodoraslo.xyz/hackbook/ - 2022-12-24T12:23:54+02:00 https://vodoraslo.xyz/hackbook/05-01-scripts-05/ 2022-12-24T12:22:57+02:00 @@ -193,9 +199,6 @@ https://vodoraslo.xyz/hackbook/00-00-hackbookeasypeasy/ 2022-12-19T22:01:36+02:00 - - https://vodoraslo.xyz/tags/blog/ - 2022-12-17T22:33:25+02:00 https://vodoraslo.xyz/blog/pluralization-issues/ 2022-12-17T22:33:25+02:00 diff --git a/new-site/public/tags/blog/index.html b/new-site/public/tags/blog/index.html index a859a947..790f90df 100644 --- a/new-site/public/tags/blog/index.html +++ b/new-site/public/tags/blog/index.html @@ -17,7 +17,8 @@


diff --git a/new-site/public/tags/blog/index.xml b/new-site/public/tags/blog/index.xml index 722b94df..be8f56da 100644 --- a/new-site/public/tags/blog/index.xml +++ b/new-site/public/tags/blog/index.xml @@ -5,11 +5,123 @@ Recent content in blog on vodoraslo Hugo -- gohugo.io en-us - Sat, 17 Dec 2022 22:33:25 +0200 + Tue, 03 Jan 2023 22:36:03 +0200 + + Multiple Index Pages in Hugo + https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/ + Tue, 03 Jan 2023 22:36:03 +0200 + + https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/ + <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> + + Yoinked some Css and updated the site https://vodoraslo.xyz/blog/yoinked-css/ diff --git a/new-site/public/tags/index.html b/new-site/public/tags/index.html index 543bcdf3..dd326fea 100644 --- a/new-site/public/tags/index.html +++ b/new-site/public/tags/index.html @@ -17,8 +17,8 @@


diff --git a/new-site/public/tags/index.xml b/new-site/public/tags/index.xml index b8f16e8e..b147b7f9 100644 --- a/new-site/public/tags/index.xml +++ b/new-site/public/tags/index.xml @@ -5,11 +5,123 @@ Recent content in Tags on vodoraslo Hugo -- gohugo.io en-us - Tue, 27 Dec 2022 14:24:24 +0200 + Tue, 03 Jan 2023 22:36:03 +0200 + + Multiple Index Pages in Hugo + https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/ + Tue, 03 Jan 2023 22:36:03 +0200 + + https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/ + <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> + + Yoinked some Css and updated the site https://vodoraslo.xyz/blog/yoinked-css/ diff --git a/new-site/public/tags/updates/index.html b/new-site/public/tags/updates/index.html index e291b876..90c9a96f 100644 --- a/new-site/public/tags/updates/index.html +++ b/new-site/public/tags/updates/index.html @@ -17,8 +17,8 @@


diff --git a/new-site/public/tags/updates/index.xml b/new-site/public/tags/updates/index.xml index 4f2f1390..38a3d892 100644 --- a/new-site/public/tags/updates/index.xml +++ b/new-site/public/tags/updates/index.xml @@ -10,6 +10,118 @@ + + Multiple Index Pages in Hugo + https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/ + Tue, 03 Jan 2023 22:36:03 +0200 + + https://vodoraslo.xyz/blog/multiple-index-pages-in-hugo/ + <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> + + Yoinked some Css and updated the site https://vodoraslo.xyz/blog/yoinked-css/ diff --git a/new-site/static/img/custom-index-directory.PNG b/new-site/static/img/custom-index-directory.PNG new file mode 100644 index 00000000..1c6ca3a0 Binary files /dev/null and b/new-site/static/img/custom-index-directory.PNG differ diff --git a/new-site/static/img/layout-custom-index.PNG b/new-site/static/img/layout-custom-index.PNG new file mode 100644 index 00000000..6517e809 Binary files /dev/null and b/new-site/static/img/layout-custom-index.PNG differ diff --git a/new-site/themes/lugo/layouts/_default/hackbook/order-by-oldest.html b/new-site/themes/lugo/layouts/_default/hackbook/order-by-oldest.html new file mode 100644 index 00000000..1da4e7ff --- /dev/null +++ b/new-site/themes/lugo/layouts/_default/hackbook/order-by-oldest.html @@ -0,0 +1,17 @@ +{{ define "title" -}} +{{ .Title | title }} +{{- end }} +{{ define "main" -}} +{{ .Content }} +
    +{{- range.Pages.Reverse }} +
  • + {{- if .Param "datesinlist" }} – {{ end -}} + {{ .Title }} + {{- if .Param "authorsinlist" }} + {{- range .Param "authors" }} by {{ . }}{{ end -}} + {{ end -}} +
  • +{{- end }} +
+{{- end }}