From 33ac2cfe541d9ca7b09d2dba1f39612ac94c6f0c Mon Sep 17 00:00:00 2001 From: Yihui Xie Date: Tue, 11 Jul 2017 22:13:57 -0500 Subject: support a placeholder when a post does not have any categories --- exampleSite/content/about.md | 1 + layouts/_default/list.html | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/exampleSite/content/about.md b/exampleSite/content/about.md index 30de0f4..aaa898b 100644 --- a/exampleSite/content/about.md +++ b/exampleSite/content/about.md @@ -93,6 +93,7 @@ There are a few phrases that you can "translate" (I didn't use Hugo's multi-lang edit = "Edit this page" tags = "Tags: " truncated = " …" + uncategorized = "Uncategorized" ``` You can define a data file under `data/` to store all authors information, e.g., you can use a TOML file `data/authors.toml` (or YAML/JSON): diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 8fb0d0b..459fa76 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -5,13 +5,15 @@ {{ $paginator := .Paginate (where .Data.Pages "Section" "!=" "") }} {{ range $paginator.Pages }}
+
{{ with .Params.categories }} {{ range first 1 . }} - {{ end }} + {{ else }} + {{ default "Uncategorized" .Site.Params.text.uncategorized }} {{ end }} +

{{ .Title }}

{{ .Date.Format "2006/01/02" }} -- cgit v1.2.3