diff options
author | Yihui Xie <xie@yihui.name> | 2017-07-13 19:18:04 +0300 |
---|---|---|
committer | Yihui Xie <xie@yihui.name> | 2017-07-13 19:20:29 +0300 |
commit | 15aec575271a335bbdef4efe1260744aad94323d (patch) | |
tree | b458774a0603b9932e10564b8dc08185e9a13328 | |
parent | 27d9ebc2f4d3b4470f98d33a52a12f42d314a0d9 (diff) |
factor out banner to make it more customizable
-rw-r--r-- | exampleSite/content/about.md | 2 | ||||
-rw-r--r-- | layouts/partials/banner.html | 7 | ||||
-rw-r--r-- | layouts/partials/header.html | 6 |
3 files changed, 9 insertions, 6 deletions
diff --git a/exampleSite/content/about.md b/exampleSite/content/about.md index aaa898b..d8e7583 100644 --- a/exampleSite/content/about.md +++ b/exampleSite/content/about.md @@ -109,7 +109,7 @@ To add a table of contents to an article, you can add `toc: true` to the YAML me # Custom layouts -Besides the custom layout^[If this is the first time you have heard about "customizing layouts", please read the Hugo documentation first: https://gohugo.io/themes/customizing/.] files `head_custom.html` and `foot_custom.html` supported in **XMin** (see [documentation](https://xmin.yihui.name/about/)), this theme added two more layout files `comments.html` and `info.html` under `layouts/partials/`. The former can be used to add a comment section, e.g., if you want to use Hugo's default Disqus template, just add this to `comments.html`: +Besides the custom layout^[If this is the first time you have heard about "customizing layouts", please read the Hugo documentation first: https://gohugo.io/themes/customizing/.] files `head_custom.html` and `foot_custom.html` supported in **XMin** (see [documentation](https://xmin.yihui.name/about/)), this theme added a few more layout files `banner.html`, `comments.html` and `info.html` under `layouts/partials/`. The first can be used to customize the banner. The second can be used to add a comment section, e.g., if you want to use Hugo's default Disqus template, just add this to `comments.html`: ``` {{ template "_internal/disqus.html" . }} diff --git a/layouts/partials/banner.html b/layouts/partials/banner.html new file mode 100644 index 0000000..cc4181c --- /dev/null +++ b/layouts/partials/banner.html @@ -0,0 +1,7 @@ +<div class="banner"> +<a href="{{ relURL .Site.BaseURL }}"{{ if not .Site.Params.banner }} class="text"{{ end }}> +{{ with .Site.Params.banner }} +<img src="{{ relURL .src }}" alt="{{ .alt }}" /> +{{ else }}{{ (replaceRE "(&[A-Z]) (fr;)" "$1$2" (replaceRE "([A-Z])" "&$1 fr;" (upper .Site.Title))) | safeHTML }} +{{ end }}</a> +</div> diff --git a/layouts/partials/header.html b/layouts/partials/header.html index ebab038..bff1bd1 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -11,11 +11,7 @@ <body{{if .IsPage}} class="page"{{ end }}> <nav class="header"> - <div class="banner"><a href="{{ relURL .Site.BaseURL }}"{{ if not .Site.Params.banner }} class="text"{{ end }}> - {{ with .Site.Params.banner }} - <img src="{{ relURL .src }}" alt="{{ .alt }}" /> - {{ else }}{{ (replaceRE "(&[A-Z]) (fr;)" "$1$2" (replaceRE "([A-Z])" "&$1 fr;" (upper .Site.Title))) | safeHTML }} - {{ end }}</a></div> + {{ partial "banner.html" . }} <div class="head-meta"> {{ if .IsPage }} <span><a href="{{ relURL .Site.BaseURL }}">{{ (default "Back to Home" .Site.Params.text.back) | safeHTML }}</a></span> |