Skip to content

Commit 677a6ec

Browse files
funnelfiascomlieberman85
authored andcommitted
Add support for post tags
This makes it easier to see the posts in a series, etc. I will tag existing posts in a subsequent commit. This one is just the infrastructure necessary to support it. Partial implementation of #50 Signed-off-by: Ben Cotton <ben@kusari.dev>
1 parent 0b81bb4 commit 677a6ec

File tree

4 files changed

+74
-7
lines changed

4 files changed

+74
-7
lines changed

README.md

+19-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ Other formats *might* work, but why take chances?)
3131
This is the date used by Hugo to sort the posts.
3232
*If you use a date in the future, it will not be listed on the blog page.*
3333
* `authors` (optional): An array of names to list as the author.
34-
If you only have one author, it still needs to be quoted and in square brackets.
34+
If you only have one author, it still needs to be quoted and in square brackets or in a yaml list format.
35+
* `tags` (optional): An array of tags to use for the post.
36+
Prefer existing tags whenever possible.
37+
When in doubt, don't add a tag.
38+
An incomplete list of tags we use is given below.
3539

3640
A complete header looks something like:
3741

@@ -40,17 +44,29 @@ A complete header looks something like:
4044
title: This is a great blog post
4145
date: 2023-04-13
4246
authors: ["Ben Cotton", "Jane Doe", "Blogger McBlogface"]
47+
tags:
48+
- releases
49+
- events
4350
---
4451
```
4552

4653
Below the header, write the content.
4754
For ease of writing, use Markdown by default.
4855
You may use HTML when needed.
4956

57+
#### Tags
58+
59+
This is a partial list of tags we use on blog posts.
60+
If you use a new tag, add it here.
61+
62+
* *community*: Posts about the community itself
63+
* *docs*: Posts about the documentation
64+
* *events*: Conferences, webinars,etc
65+
* *meetings*: Community Meetings and Maintainers Meetings
66+
* *releases*: Release announcements
67+
5068
## Layout
5169

5270
* config.yml — Site configuration and main page content
5371
* content/blog/* — Blog posts
5472
* content/* — Other pages
55-
56-

config.yaml

+1-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ outputs:
1111
section:
1212
- html
1313
- rss
14-
# Disables warnings
15-
disableKinds:
16-
- taxonomy
17-
- taxonomyTerm
1814
services:
1915
rss:
2016
limit: 10
@@ -24,6 +20,7 @@ markup:
2420
unsafe: true # Allows you to write raw html in your md files
2521

2622
params:
23+
date_format: "2006-01-02"
2724
include_footer: true
2825
# Open graph allows easy social sharing. If you don't want it you can set it to false or just delete the variable
2926
openGraph: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<!DOCTYPE html>
2+
<html lang="{{ .Site.LanguageCode }}">
3+
<head>
4+
{{ partial "meta.html" . }}
5+
<title>{{ block "title" . }}{{ .Site.Title }}{{ end }}</title>
6+
{{ partial "css.html" . }}
7+
</head>
8+
<body>
9+
<!-- Preloader -->
10+
<div id="preloader">
11+
<div id="status"></div>
12+
</div>
13+
14+
{{ partial "navbar.html" . }}
15+
{{ partial "navbar-clone.html" . }}
16+
17+
<section class="section is-medium">
18+
<div class="container">
19+
<div class="columns">
20+
<div class="column is-centered-tablet-portrait">
21+
22+
<h1 class="title section-title">{{ .Title }} posts</h1>
23+
{{ .Content }}
24+
{{ range .Pages }}
25+
<p>{{ .Date.Format .Site.Params.date_format }} — <a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></p>
26+
{{ end }}
27+
28+
</div>
29+
</div>
30+
</div>
31+
</section>
32+
33+
{{ $include_footer := .Params.include_footer | default .Site.Params.include_footer }}
34+
{{ if $include_footer }}
35+
{{ partial "footer.html" . }}
36+
{{ end }}
37+
38+
39+
<!-- Back To Top Button -->
40+
<div id="backtotop"><a href="#"></a></div>
41+
42+
{{ if .Params.sidebar }}
43+
{{ partial "single/sidebar.html" . }}
44+
{{ end }}
45+
46+
{{ partial "javascript.html" . }}
47+
48+
</body>
49+
</html>

themes/hugo-fresh/layouts/partials/single/content.html

+5
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,10 @@ <h5 class="subtitle is-5 is-muted">{{ .Params.Subtitle }}</h5>
1818
<div class="content">
1919
{{ .Content }}
2020
</div>
21+
22+
{{ if gt (.Param "tags") 0 }}
23+
{{ $maxIndex := sub ( len .Params.tags ) 1 }}
24+
<p class="tagList">Tags: {{ range $index, $tag := .Param "tags" }}<a href="/tags/{{ $tag }}">{{ $tag }}</a>{{ if and ( ne $maxIndex 0 ) ( lt $index $maxIndex ) }} | {{ end }}{{ end }}</p>
25+
{{ end }}
2126
</div>
2227
</section>

0 commit comments

Comments
 (0)