From c8bf719e3d4a4c6ed1e70c5091f72e542ffc7a3d Mon Sep 17 00:00:00 2001 From: vimux Date: Tue, 30 Jul 2019 17:32:26 -0400 Subject: [PATCH] Define the Base Template and fix Hugo warnings * Define the Base Template (baseof.html) * Use relative URL link to style.css file * Move summary.html from partials to _default layouts * Fix Hugo warnings (needs Hugo 0.20 or newer) * Fix Paginator rule on main page. Fix #8 * Latest posts: show pages from mainSections only * Bump Hugo 0.19 -> 0.20 * Formatting --- layouts/_default/baseof.html | 20 ++++++++++++++++++++ layouts/_default/list.html | 16 +++++++++++----- layouts/_default/single.html | 6 +++--- layouts/_default/summary.html | 13 +++++++++++++ layouts/index.html | 8 ++++---- layouts/partials/footer.html | 8 +++----- layouts/partials/header.html | 34 ++++++++++------------------------ layouts/partials/sidebar.html | 24 ++++++++++++------------ layouts/partials/summary.html | 13 ------------- theme.toml | 2 +- 10 files changed, 77 insertions(+), 67 deletions(-) create mode 100644 layouts/_default/baseof.html create mode 100644 layouts/_default/summary.html delete mode 100644 layouts/partials/summary.html diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html new file mode 100644 index 0000000..33e5cda --- /dev/null +++ b/layouts/_default/baseof.html @@ -0,0 +1,20 @@ + + + + + + + {{ .Title }} + {{ with .Site.Params.description }}{{ end }} + {{ with .Site.Params.author }}{{ end }} + + {{ with .OutputFormats.Get "RSS" -}} + {{ printf `` .Rel .MediaType.Type .RelPermalink $.Site.Title | safeHTML }} + {{- end }} + + + {{ partial "header" . }} + {{ block "main" . }}{{ end }} + {{ partial "footer" . }} + + diff --git a/layouts/_default/list.html b/layouts/_default/list.html index bc7f4e6..68fb00c 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,10 +1,16 @@ -{{ partial "header.html" . }} +{{ define "main" }}
- {{ $paginator := .Paginate (where .Data.Pages "Type" "post") }} - {{ range $paginator.Pages }} - {{ partial "summary.html" . }} + {{ if or .Title .Content }} +
+ {{ with .Title }}

{{ . }}

{{ end }} + {{ with .Content }}
{{ . }}
{{ end }} +
+ {{ end }} + + {{ range .Paginator.Pages }} + {{ .Render "summary" }} {{ end }} {{ partial "pagination.html" . }}
{{ partial "sidebar.html" . }} -{{ partial "footer.html" . }} +{{ end }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 4593944..af8398c 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,4 +1,4 @@ -{{ partial "header.html" . }} +{{ define "main" }}

{{ .Title }}

@@ -9,7 +9,7 @@
@@ -19,4 +19,4 @@
{{ partial "sidebar.html" . }} -{{ partial "footer.html" . }} +{{ end }} diff --git a/layouts/_default/summary.html b/layouts/_default/summary.html new file mode 100644 index 0000000..9acf434 --- /dev/null +++ b/layouts/_default/summary.html @@ -0,0 +1,13 @@ +
+

{{ .Title }}

+ + {{ range .Params.tags }} + {{ . }} + {{ end }} +
+ {{ .Summary }} + {{ if .Truncated }} + Read more... + {{ end }} +
+
diff --git a/layouts/index.html b/layouts/index.html index 56c41f3..ab01f67 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,10 +1,10 @@ -{{ partial "header.html" . }} +{{ define "main" }}
- {{ $paginator := .Paginate (where .Site.Pages "Type" "post") }} + {{ $paginator := .Paginate (where .Site.RegularPages "Type" "in" .Site.Params.mainSections) }} {{ range $paginator.Pages }} - {{ partial "summary.html" . }} + {{ .Render "summary" }} {{ end }} {{ partial "pagination.html" . }}
{{ partial "sidebar.html" . }} -{{ partial "footer.html" . }} +{{ end }} diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 6551e25..a34c170 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -1,5 +1,3 @@ - - - + diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 9a9179c..86e0e27 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -1,24 +1,10 @@ - - - - - - - {{ .Title }} - {{ with .Site.Params.description }}{{ end }} - {{ with .Site.Params.author }}{{ end }} - - {{ if .RSSLink -}}{{- end }} - {{ .Hugo.Generator }} - - -
- {{ .Site.Title }} - -
+
+ {{ .Site.Title }} + +
diff --git a/layouts/partials/sidebar.html b/layouts/partials/sidebar.html index 679b16e..92bbd80 100644 --- a/layouts/partials/sidebar.html +++ b/layouts/partials/sidebar.html @@ -1,14 +1,14 @@ - diff --git a/layouts/partials/summary.html b/layouts/partials/summary.html deleted file mode 100644 index aadf63b..0000000 --- a/layouts/partials/summary.html +++ /dev/null @@ -1,13 +0,0 @@ -
-

{{ .Title }}

- - {{ range .Params.tags }} - {{ . }} - {{ end }} -
- {{ .Summary }} - {{ if .Truncated }} - Read more... - {{ end }} -
-
diff --git a/theme.toml b/theme.toml index 15f0f63..559d2c6 100644 --- a/theme.toml +++ b/theme.toml @@ -5,7 +5,7 @@ description = "Starter Hugo theme for developers." homepage = "https://github.com/vimux/blank/" tags = ["blog", "plain", "blank", "starter"] features = ["blog"] -min_version = 0.19 +min_version = 0.20 [author] name = "Vimux"