Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/rmaguiar/hugo-theme-color-your-world.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphael Aguiar <rmaguiar@tuta.io>2020-08-28 19:32:29 +0300
committerRaphael Aguiar <rmaguiar@tuta.io>2020-08-28 19:32:29 +0300
commit3c7b035b1b8e3481b666bc53859049f624d721a5 (patch)
tree5003da029f4ffaaa40f9474e98f17270691301f9
parent91bb69cd7c7f7570359b544ae8427c12895ca262 (diff)
Update RSS template and minor changes
* Update RSS template * Add some custom front matter params to the README * Other minor changes
-rw-r--r--README.md12
-rw-r--r--assets/scss/main.scss2
-rw-r--r--exampleSite/config.toml2
-rw-r--r--exampleSite/content/posts/readme.md13
-rw-r--r--layouts/404.html4
-rw-r--r--layouts/_default/baseof.html4
-rw-r--r--layouts/_default/rss.xml2
-rw-r--r--layouts/_default/search.json.json1
-rw-r--r--layouts/_default/single.html14
-rw-r--r--layouts/_default/sitemap.xml57
-rw-r--r--layouts/index.html13
-rw-r--r--layouts/partials/footer.html6
-rw-r--r--layouts/partials/head.html16
-rw-r--r--layouts/partials/header.html2
-rw-r--r--layouts/partials/table-of-contents.html9
15 files changed, 98 insertions, 59 deletions
diff --git a/README.md b/README.md
index 975f884..da5e968 100644
--- a/README.md
+++ b/README.md
@@ -241,6 +241,12 @@ A **really** basic 404 page can be generated via config file by using:
paragraph = "Nothing to see here, buddy."
```
+### Custom front matter params
+
+* `mainTitle` (string): Can be used to replace the `<title>` meta tag, if you wish it to be different from the `<h1>` (which will still use the `title` param);
+* `sitemapExclude` (true|false): Can be used to exclude a page/section from the sitemap;
+* `noindex` (true|false): Similar to the above. Can be used to exclude a page/section from being indexed (by bots or your own site). It will change the meta tag `robots` to `noindex` and the page(s) will not be added to the site's search index.
+
### Custom partials
* The site title can be replaced by creating a file named `layouts/partials/custom/site-title.html`;
@@ -248,9 +254,9 @@ A **really** basic 404 page can be generated via config file by using:
* Custom CSS can be imported into the main CSS file by creating a file named `static/css/custom.css` or `assets/scss/custom.scss`;
* The `copyright` param can be replaced by creating a file named `layouts/partials/custom/copyright.html`.
-### More config
+### More params
-More possible params for your config file:
+More possible params for your config file (or front matter):
```toml
[params]
@@ -288,9 +294,9 @@ More possible params for your config file:
markupImgClass = "borderless"
# This will append a separator (of your choice) along the site title to your <title>
+ # ie.: | ❚ - – — • ⚫
# You can disabled it PER PAGE by using "disableTitleSeparator" at front
# matter or disable it entirely by commenting the line below
- # ie.: | ❚ - – — • ⚫
titleSeparator = "|"
[params.search]
diff --git a/assets/scss/main.scss b/assets/scss/main.scss
index c9ce8bd..e1936e0 100644
--- a/assets/scss/main.scss
+++ b/assets/scss/main.scss
@@ -338,7 +338,7 @@ code {
// If there's no "custom/site-title" partial, style a default one
-{{ if not (or (templates.Exists "partials/custom/site-title") (templates.Exists "partials/custom/site-title.html")) }}
+{{ if not (templates.Exists "partials/custom/site-title.html") }}
body > header {
> a {
@extend %heading-base;
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index fdebfd9..8566f3f 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -57,9 +57,9 @@ paginate = 5
markupImgClass = ""
# This will append a separator (of your choice) along the site title to your <title>
+ # ie.: | ❚ - – — • ⚫
# You can disabled it PER PAGE by using "disableTitleSeparator" at front
# matter or disable it entirely by commenting the line below
- # ie.: | ❚ - – — • ⚫
titleSeparator = "|"
diff --git a/exampleSite/content/posts/readme.md b/exampleSite/content/posts/readme.md
index 2922bc9..b9d473c 100644
--- a/exampleSite/content/posts/readme.md
+++ b/exampleSite/content/posts/readme.md
@@ -2,6 +2,7 @@
title : "Read Me"
description : "A copy of the README.md file."
tags : [ extra, markdown ]
+toc : true
---
[Live demo (on Netlify)](https://color-your-world-demo.netlify.app/) | [Demo (on Hugo Themes)](https://themes.gohugo.io/theme/hugo-theme-color-your-world/)
@@ -245,6 +246,12 @@ A **really** basic 404 page can be generated via config file by using:
paragraph = "Nothing to see here, buddy."
```
+### Custom front matter params
+
+* `mainTitle` (string): Can be used to replace the `<title>` meta tag, if you wish it to be different from the `<h1>` (which will still use the `title` param);
+* `sitemapExclude` (true|false): Can be used to exclude a page/section from the sitemap;
+* `noindex` (true|false): Similar to the above. Can be used to exclude a page/section from being indexed (by bots or your own site). It will change the meta tag `robots` to `noindex` and the page(s) will not be added to the site's search index.
+
### Custom partials
* The site title can be replaced by creating a file named `layouts/partials/custom/site-title.html`;
@@ -252,9 +259,9 @@ A **really** basic 404 page can be generated via config file by using:
* Custom CSS can be imported into the main CSS file by creating a file named `static/css/custom.css` or `assets/scss/custom.scss`;
* The `copyright` param can be replaced by creating a file named `layouts/partials/custom/copyright.html`.
-### More config
+### More params
-More possible params for your config file:
+More possible params for your config file (or front matter):
```toml
[params]
@@ -292,9 +299,9 @@ More possible params for your config file:
markupImgClass = "borderless"
# This will append a separator (of your choice) along the site title to your <title>
+ # ie.: | ❚ - – — • ⚫
# You can disabled it PER PAGE by using "disableTitleSeparator" at front
# matter or disable it entirely by commenting the line below
- # ie.: | ❚ - – — • ⚫
titleSeparator = "|"
[params.search]
diff --git a/layouts/404.html b/layouts/404.html
index 9de2956..9b99da1 100644
--- a/layouts/404.html
+++ b/layouts/404.html
@@ -1,8 +1,8 @@
{{ define "main" }}
<main>
- <h1>{{ .Site.Params.notFound.title | default .Site.Data.default.notFound.title }}</h1>
- <p>{{ .Site.Params.notFound.paragraph | default .Site.Data.default.notFound.paragraph }}</p>
+ <h1>{{ .Site.Params.notFound.title | emojify | default .Site.Data.default.notFound.title }}</h1>
+ <p>{{ .Site.Params.notFound.paragraph | emojify | default .Site.Data.default.notFound.paragraph }}</p>
</main>
{{ end }}
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index b6b0682..fd10f53 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -4,7 +4,7 @@
Currently here to avoid certain priority issues...
-->
-{{- .Scratch.Set "imageProc" (dict "highRes" (.Site.Params.imageProc.highRes | default .Site.Data.default.imageProc.highRes) "mediumRes" (.Site.Params.imageProc.mediumRes | default .Site.Data.default.imageProc.mediumRes) "lowRes" (.Site.Params.imageProc.lowRes | default .Site.Data.default.imageProc.lowRes) "markupAutoResizeWidth" (.Site.Params.imageProc.markupAutoResizeWidth | default .Site.Data.default.imageProc.markupAutoResizeWidth)) }}
+{{- .Scratch.Set "imageProc" (dict "highRes" (.Site.Params.imageProc.highRes | default .Site.Data.default.imageProc.highRes) "mediumRes" (.Site.Params.imageProc.mediumRes | default .Site.Data.default.imageProc.mediumRes) "lowRes" (.Site.Params.imageProc.lowRes | default .Site.Data.default.imageProc.lowRes) "markupAutoResizeWidth" (.Site.Params.imageProc.markupAutoResizeWidth | default .Site.Data.default.imageProc.markupAutoResizeWidth)) -}}
<!DOCTYPE html>
<html lang="{{ .Site.Language.Lang }}" data-mode="{{ if .Site.Params.Style.isDark }}dark{{ else }}light{{ end }}">
@@ -82,7 +82,7 @@
<!-- KaTeX -->
{{ if or .Params.katex .Site.Params.katex .Params.math .Site.Params.math }}
- {{ partial "katex.html" . }}
+ {{ partial "katex" . }}
{{ end }}
</body>
diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml
index eb0f835..8d0c681 100644
--- a/layouts/_default/rss.xml
+++ b/layouts/_default/rss.xml
@@ -6,7 +6,7 @@
{{- else -}}
{{- $pages = $pctx.Pages -}}
{{- end -}}
-{{- $pages = where $pages "Params.sitemapexclude" "ne" true -}}
+{{- $pages = where $pages "Params.noindex" "ne" true -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
diff --git a/layouts/_default/search.json.json b/layouts/_default/search.json.json
index 279aeb2..e401800 100644
--- a/layouts/_default/search.json.json
+++ b/layouts/_default/search.json.json
@@ -1,6 +1,7 @@
{{- $stopWords := or .Params.stopWords .Site.Params.Search.stopWords -}}
{{- $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections -}}
+{{- $pages = where $pages "Params.noindex" "ne" true -}}
{{- $lastIndex := (sub (len $pages) 1) -}}
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index 48c7aee..3b32bde 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -4,11 +4,7 @@
<article>
<header>
- <h1>{{ .Title }}</h1>
-
- {{ range .Data.Terms }}
- {{ .Name }}
- {{ end }}
+ <h1>{{ .Title | emojify }}</h1>
{{ if or .Params.categories .Params.tags }}
<section class="terms">
@@ -39,13 +35,7 @@
</header>
- {{ if .Params.toc }}
- <details class="toc" open>
- <summary class="outline-dashed">{{ T "tableOfContents" }}</summary>
- {{ .Page.TableOfContents }}
- </details>
- {{ end }}
-
+ {{ partial "table-of-contents" . }}
{{ partial "processed-content" . }}
</article>
diff --git a/layouts/_default/sitemap.xml b/layouts/_default/sitemap.xml
index 8177b07..b42a7af 100644
--- a/layouts/_default/sitemap.xml
+++ b/layouts/_default/sitemap.xml
@@ -1,29 +1,42 @@
+{{- $pages := .RegularPages -}}
+{{- $pages = where $pages "Params.sitemapexclude" "ne" true -}}
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" | safeHTML }}
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
- {{ range .Site.RegularPages }}
- {{ if not .Params.sitemapExclude }}
- <url>
- <loc>{{ .Permalink }}</loc>
-
- {{ if not .Lastmod.IsZero }}
- <lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>
- {{ end }}
-
- {{ with .Sitemap.ChangeFreq }}
- <changefreq>{{ . }}</changefreq>
- {{ end }}
-
- {{ if ge .Sitemap.Priority 0.0 }}
- <priority>{{ .Sitemap.Priority }}</priority>
+ {{ range $pages }}
+
+ <url>
+ <loc>{{ .Permalink }}</loc>
+
+ {{ if not .Lastmod.IsZero }}
+ <lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>
+ {{ end }}
+
+ {{ with .Sitemap.ChangeFreq }}
+ <changefreq>{{ . }}</changefreq>
+ {{ end }}
+
+ {{ if ge .Sitemap.Priority 0.0 }}
+ <priority>{{ .Sitemap.Priority }}</priority>
+ {{ end }}
+
+ {{ if .IsTranslated }}
+ {{ range .Translations }}
+ <xhtml:link
+ rel="alternate"
+ hreflang="{{ .Lang }}"
+ href="{{ .Permalink }}"
+ />
{{ end }}
- {{ if .IsTranslated }}
- {{ range .Translations }}
- <xhtml:link rel="alternate" hreflang="{{ .Lang }}" href="{{ .Permalink }}" />
- {{ end }}
- {{ end }}
- </url>
- {{ end }}
+ <xhtml:link
+ rel="alternate"
+ hreflang="{{ .Lang }}"
+ href="{{ .Permalink }}"
+ />
+ {{ end }}
+
+ </url>
+
{{ end }}
</urlset> \ No newline at end of file
diff --git a/layouts/index.html b/layouts/index.html
index dc92444..566e19d 100644
--- a/layouts/index.html
+++ b/layouts/index.html
@@ -6,9 +6,20 @@
{{ if .Content }}
<article>
- <h1>{{ .Title | emojify }}</h1>
+
+ <header>
+
+ <h1>{{ .Title | emojify }}</h1>
+
+ {{ if .Params.cover }}
+ {{ partial "cover" . }}
+ {{ end }}
+
+ </header>
+ {{ partial "table-of-contents" . }}
{{ partial "processed-content" . }}
+
</article>
{{ else }}
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index 9ea8cee..b314f1b 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -1,8 +1,10 @@
<!-- Custom or default copyright -->
-{{ if or (templates.Exists "partials/custom/copyright") (templates.Exists "partials/custom/copyright.html") }}
+{{ if (templates.Exists "partials/custom/copyright.html") }}
{{ partial "custom/copyright" . }}
{{ else }}
- <p>{{ .Site.Copyright | markdownify | emojify }}</p>
+ {{ with .Site.Copyright }}
+ <p>{{ . | markdownify | emojify }}</p>
+ {{ end }}
{{ end }}
<!--
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 7509980..d950a45 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -3,8 +3,8 @@
<meta name="generator" content="Hugo {{ hugo.Version }} -- gohugo.io / Color Your World -- gitlab.com/rmaguiar/hugo-theme-color-your-world">
<!-- I'm 99% sure there's a smarter way of doing it but whatever -->
-{{ $currentTitle := (.Title | emojify) }}
-{{ $mainTitle := .Params.mainTitle }}
+{{ $currentTitle := .Title | emojify }}
+{{ $mainTitle := .Params.mainTitle | emojify }}
{{ $titleSeparator := .Site.Params.titleSeparator }}
@@ -13,7 +13,7 @@
{{ if (eq .Kind "404") }}
<!-- If 404 page -->
- {{ $currentTitle = .Site.Params.notFound.title | default .Site.Data.default.notFound.title }}
+ {{ $currentTitle = .Site.Params.notFound.title | emojify | default .Site.Data.default.notFound.title }}
{{ else if (eq .Kind "section") }}
@@ -53,15 +53,15 @@
{{ else if and (.IsHome) (not .Content) }}
<!-- If home page without content -->
- {{ $currentTitle = (.Site.Title | emojify) }}
+ {{ $currentTitle = .Site.Title | emojify }}
{{ end }}
-{{ $currentDesc := (.Params.Description | emojify) }}
+{{ $currentDesc := .Params.Description | emojify }}
{{ if .IsHome }}
- {{ $currentDesc = (.Site.Params.description | emojify) }}
+ {{ $currentDesc = .Site.Params.description | emojify }}
{{ else if and (ne .Kind "taxonomy") (eq .Type "tags") (not .Params.description) }}
{{ $currentDesc = (T "postsUnderTag" .) }}
{{ else if and (ne .Kind "taxonomy") (eq .Type "categories") (not .Params.description) }}
@@ -69,7 +69,7 @@
{{ else if eq .Kind "taxonomy" }}
{{ $currentDesc = printf "%s %s." (T "pageContaining") ($currentTitle | lower) }}
{{ else if (eq .Kind "404") }}
- {{ $currentDesc = .Site.Params.notFound.description | default .Site.Data.default.notFound.description }}
+ {{ $currentDesc = .Site.Params.notFound.description | emojify | default .Site.Data.default.notFound.description }}
{{ end }}
@@ -126,7 +126,7 @@
<!-- If the user wants to add something (custom favicons, fonts, scripts, etc) -->
-{{ if or (templates.Exists "partials/custom/head-append") (templates.Exists "partials/custom/head-append.html") }}
+{{ if (templates.Exists "partials/custom/head-append.html") }}
{{ partial "custom/head-append" . }}
{{ end }}
diff --git a/layouts/partials/header.html b/layouts/partials/header.html
index 83e9cfc..8c148f8 100644
--- a/layouts/partials/header.html
+++ b/layouts/partials/header.html
@@ -1,5 +1,5 @@
<!-- Custom or default site title -->
-{{ if or (templates.Exists "partials/custom/site-title") (templates.Exists "partials/custom/site-title.html") }}
+{{ if (templates.Exists "partials/custom/site-title.html") }}
{{ partial "custom/site-title" . }}
{{ else }}
<a href="{{ .Site.BaseURL | relLangURL }}">{{ .Site.Title }}</a>
diff --git a/layouts/partials/table-of-contents.html b/layouts/partials/table-of-contents.html
new file mode 100644
index 0000000..2ccd8cc
--- /dev/null
+++ b/layouts/partials/table-of-contents.html
@@ -0,0 +1,9 @@
+{{ if .Params.toc }}
+ <details class="toc" open>
+ <summary class="outline-dashed">
+ {{ T "tableOfContents" }}
+ </summary>
+
+ {{ .Page.TableOfContents }}
+ </details>
+{{ end }} \ No newline at end of file