Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zwbetz-gh/minimal-bootstrap-hugo-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGianmarco Brocchi <gianmarcobrocchi@gmail.com>2022-01-13 17:39:21 +0300
committerGitHub <noreply@github.com>2022-01-13 17:39:21 +0300
commit450a72a1ee434c758d9467190fc7b2607b2e59a0 (patch)
tree404c66a22a87d7a4515d35d44e60837326c59282
parent31b337de325667020f1cc3b7c1766acd9b01b935 (diff)
Show categories next to tags in a post (#18)
Add categories in post archetype Add categories in taxonomy of exampleSite
-rw-r--r--archetypes/post.md1
-rw-r--r--exampleSite/config.toml3
-rw-r--r--layouts/partials/categories.html4
-rw-r--r--layouts/post/single.html4
4 files changed, 9 insertions, 3 deletions
diff --git a/archetypes/post.md b/archetypes/post.md
index 67ec913..c9ca8e8 100644
--- a/archetypes/post.md
+++ b/archetypes/post.md
@@ -5,4 +5,5 @@ publishdate: {{ now.Format "2006-01-02" }}
lastmod: {{ now.Format "2006-01-02" }}
draft: true
tags: []
+categories: []
---
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 1795e21..9b7c494 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -5,6 +5,7 @@ theme = "minimal-bootstrap-hugo-theme"
[taxonomies]
tag = "tags"
+ category = "categories"
[permalinks]
post = "/:filename/"
@@ -77,4 +78,4 @@ theme = "minimal-bootstrap-hugo-theme"
tabWidth = 4
[markup.tableOfContents]
endLevel = 6
- startLevel = 2 \ No newline at end of file
+ startLevel = 2
diff --git a/layouts/partials/categories.html b/layouts/partials/categories.html
new file mode 100644
index 0000000..85ebf1d
--- /dev/null
+++ b/layouts/partials/categories.html
@@ -0,0 +1,4 @@
+{{ range .Params.categories }}
+{{ $href := print (absURL "categories/") (urlize .) }}
+<small><code>[<a href="{{ $href }}">{{ . }}</a>]</code></small>
+{{ end }}
diff --git a/layouts/post/single.html b/layouts/post/single.html
index 9e34d6c..d59e499 100644
--- a/layouts/post/single.html
+++ b/layouts/post/single.html
@@ -7,8 +7,8 @@
{{ with .Site.Params.customDateFormat }}{{ $customDateFormat = . }}{{ end }}
{{ .PublishDate.Format $customDateFormat }}{{ if gt .Lastmod .PublishDate }}, updated {{ .Lastmod.Format $customDateFormat }}{{ end }}
</small>
- {{ partial "tags" . }}
+ {{ partial "tags" . }} {{ partial "categories" . }}
</p>
{{ .Content }}
-{{- end -}} \ No newline at end of file
+{{- end -}}