mirror of
https://github.com/alanorth/hugo-theme-bootstrap4-blog.git
synced 2024-11-24 21:20:17 +01:00
layouts: Add theme support for categories and tags
Add categories/tags to front matter and they will be displayed on summary and post pages, with links to taxonomy pages. Example: +++ date = "2016-09-24T21:28:31+03:00" title = "Post title" categories = ["Nature"] tags = ["Wetland", "Oasis"] +++ For some reason if you add tags singularly, like: categories = "Nature" you get index errors from Hugo. Not sure if I need to parse the tags differently or just add more logic to test if the terms are singular or not.
This commit is contained in:
parent
86b6689ebe
commit
884713fc2a
@ -3,7 +3,7 @@
|
|||||||
<article class="blog-post">
|
<article class="blog-post">
|
||||||
<header>
|
<header>
|
||||||
<h2 class="blog-post-title"><a href="{{ .Permalink }}" title="{{ .Title }}">{{ .Title }}</a></h2>
|
<h2 class="blog-post-title"><a href="{{ .Permalink }}" title="{{ .Title }}">{{ .Title }}</a></h2>
|
||||||
<p class="blog-post-meta"><time datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Date.Format .Site.Params.date_format }}</time> by <a href="#">{{ .Params.author | default .Site.Params.author }}</a></p>
|
<p class="blog-post-meta"><time datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Date.Format .Site.Params.date_format }}</time> by <a href="#">{{ .Params.author | default .Site.Params.author }}</a>{{ if or (.Params.categories) (.Params.tags) }} in {{ partial "meta-terms.html" . }}{{ end }}</p>
|
||||||
</header>
|
</header>
|
||||||
{{ .Content }}
|
{{ .Content }}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<article class="blog-post">
|
<article class="blog-post">
|
||||||
<header>
|
<header>
|
||||||
<h2 class="blog-post-title"><a href="{{ .Permalink }}" title="{{ .Title }}">{{ .Title }}</a></h2>
|
<h2 class="blog-post-title"><a href="{{ .Permalink }}" title="{{ .Title }}">{{ .Title }}</a></h2>
|
||||||
<p class="blog-post-meta"><time datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Date.Format .Site.Params.date_format }}</time> by <a href="#">{{ .Params.author | default .Site.Params.author }}</a></p>
|
<p class="blog-post-meta"><time datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Date.Format .Site.Params.date_format }}</time> by <a href="#">{{ .Params.author | default .Site.Params.author }}</a> {{ if or (.Params.categories) (.Params.tags) }} in {{ partial "meta-terms.html" . }}{{ end }}</p>
|
||||||
</header>
|
</header>
|
||||||
{{ .Summary }}
|
{{ .Summary }}
|
||||||
<a href='{{ .Permalink }}'>Read more →</a>
|
<a href='{{ .Permalink }}'>Read more →</a>
|
||||||
|
6
layouts/partials/meta-terms.html
Normal file
6
layouts/partials/meta-terms.html
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{{ if .Params.categories }}
|
||||||
|
<i class="fa fa-folder" aria-hidden="true"></i> {{ range $index, $category := .Params.categories }}{{ if gt $index 0 }}, {{ end }}<a href="{{ "/categories/" | relURL }}{{ . | urlize }}" rel="category tag">{{ . }}</a>{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
{{ if .Params.tags }}
|
||||||
|
<i class="fa fa-tag" aria-hidden="true"></i> {{ range $index, $tag := .Params.tags }}{{ if gt $index 0 }}, {{ end }}<a href="{{ "/tags/" | relURL }}{{ . | urlize }}" rel="tag">{{ . }}</a>{{ end }}
|
||||||
|
{{ end }}
|
Loading…
Reference in New Issue
Block a user