mirror of
https://github.com/pawroman/zola-theme-terminimal.git
synced 2025-01-08 19:51:06 +01:00
Add the ability to include page titles in HTML title element
This commit is contained in:
parent
eb82877d3d
commit
cfbcb940be
19
README.md
19
README.md
|
@ -322,6 +322,25 @@ favicon = "/favicon.png"
|
|||
favicon_mimetype = "image/png"
|
||||
```
|
||||
|
||||
### Page titles
|
||||
|
||||
The theme allows you to configure how the page titles (the `<title>` elements) are rendered.
|
||||
|
||||
Use `"combined"` to render titles as `"Page title | Main title"`.
|
||||
|
||||
```toml
|
||||
# Optional: Set how <title> elements are rendered.
|
||||
# Values:
|
||||
# - "main_only" -- only the main title (`config.title`) is rendered.
|
||||
# - "page_only" -- only the page title (if defined) is rendered,
|
||||
# falling back to `config.title` if not defined or empty.
|
||||
# - "combined" -- combine like so: "page_title | main_title",
|
||||
# or if page_title is not defined or empty, fall back to `main_title`
|
||||
#
|
||||
# Note that the main (index) page only has the main title.
|
||||
page_titles = "combined"
|
||||
```
|
||||
|
||||
All the configuration options are also described in
|
||||
[`config.toml`](../master/config.toml).
|
||||
|
||||
|
|
11
config.toml
11
config.toml
|
@ -78,3 +78,14 @@ use_full_hack_font = false
|
|||
# in your site's "static" directory.
|
||||
# favicon = "/favicon.png"
|
||||
# favicon_mimetype = "image/png"
|
||||
|
||||
# Optional: Set how <title> elements are rendered.
|
||||
# Values:
|
||||
# - "main_only" -- only the main title (`config.title`) is rendered.
|
||||
# - "page_only" -- only the page title (if defined) is rendered,
|
||||
# falling back to `config.title` if not defined or empty.
|
||||
# - "combined" -- combine like so: "page_title | main_title",
|
||||
# or if page_title is not defined or empty, fall back to `main_title`
|
||||
#
|
||||
# Note that the main (index) page only has the main title.
|
||||
page_titles = "main_only"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
+++
|
||||
title = "about me"
|
||||
title = "About Me"
|
||||
path = "about"
|
||||
+++
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
+++
|
||||
title = "Archive"
|
||||
path = "archive"
|
||||
template = "archive.html"
|
||||
title = "blog archive (all posts)"
|
||||
+++
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
+++
|
||||
title = "Terminimal Theme for Zola"
|
||||
title = "Welcome to Terminimal Theme for Zola"
|
||||
date = 2019-02-04
|
||||
|
||||
[taxonomies]
|
|
@ -1,5 +1,9 @@
|
|||
{% extends "index.html" %}
|
||||
|
||||
{%- block title -%}
|
||||
{{ title_macros::title(page_title=page.title, main_title=config.title) }}
|
||||
{%- endblock -%}
|
||||
|
||||
{% block content %}
|
||||
<div class="post">
|
||||
<h1 class="post-title">{{ page.title }}</h1>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
{% import "macros/head.html" as head_macros -%}
|
||||
{% import "macros/menu.html" as menu_macros -%}
|
||||
{% import "macros/post.html" as post_macros -%}
|
||||
{% import "macros/title.html" as title_macros -%}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="{%- if config.default_language -%}{{ config.default_language }}{%- else -%}en{%- endif -%}">
|
||||
|
|
17
templates/macros/title.html
Normal file
17
templates/macros/title.html
Normal file
|
@ -0,0 +1,17 @@
|
|||
{% macro title(page_title, main_title) %}
|
||||
{%- if config.extra.page_titles == "combined" -%}
|
||||
{%- if page_title -%}
|
||||
{{ page_title }} | {{ main_title }}
|
||||
{%- else -%}
|
||||
{{ main_title }}
|
||||
{%- endif -%}
|
||||
{%- elif config.extra.page_titles == "page_only" -%}
|
||||
{%- if page_title -%}
|
||||
{{ page_title }}
|
||||
{%- else -%}
|
||||
{{ main_title }}
|
||||
{%- endif -%}
|
||||
{%- else -%}
|
||||
{{ main_title }}
|
||||
{%- endif -%}
|
||||
{% endmacro title %}
|
|
@ -1,5 +1,9 @@
|
|||
{% extends "index.html" %}
|
||||
|
||||
{%- block title -%}
|
||||
{{ title_macros::title(page_title=page.title, main_title=config.title) }}
|
||||
{%- endblock -%}
|
||||
|
||||
{% block content %}
|
||||
<div class="post">
|
||||
{{ post_macros::header(page=page) }}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
{% extends "index.html" %}
|
||||
|
||||
{%- block title -%}
|
||||
{{ title_macros::title(page_title="Tags", main_title=config.title) }}
|
||||
{%- endblock -%}
|
||||
|
||||
{% block content %}
|
||||
<div class="post">
|
||||
<h1 class="post-title">all tags</h1>
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
{% extends "index.html" %}
|
||||
|
||||
{%- block title -%}
|
||||
{% set title = "Tag: " ~ term.name %}
|
||||
{{ title_macros::title(page_title=title, main_title=config.title) }}
|
||||
{%- endblock -%}
|
||||
|
||||
{% block content %}
|
||||
<div class="post">
|
||||
<h1 class="post-title">
|
||||
|
|
Loading…
Reference in a new issue