diff --git a/templates/base.html b/templates/base.html index 19f2fbb71..4e9c3246c 100644 --- a/templates/base.html +++ b/templates/base.html @@ -5,6 +5,7 @@ {% import "macros/content.html" as macros_content %} {% import "macros/cards_posts.html" as macros_cards_posts %} {% import "macros/list_title.html" as macros_list_title %} +{% import "macros/set_title.html" as macros_set_title %} diff --git a/templates/macros/set_title.html b/templates/macros/set_title.html new file mode 100644 index 000000000..1f609336e --- /dev/null +++ b/templates/macros/set_title.html @@ -0,0 +1,29 @@ +{% macro set_title() %} + +{# Setup. #} +{% set prefix = config.title | safe %} +{% set separator = " • " %} + +{% if current_path and current_path == "/" %} + {% set suffix = "" %} + {% set separator = "" %} +{% elif title %} + {% set suffix = title %} +{% elif section.title %} + {% set suffix = section.title %} +{% elif page.title %} + {% set suffix = page.title %} +{% elif term.name %} + {# Individual tags. #} + {% set suffix = term.name ~ " tag" %} +{% elif taxonomy.name %} + {# List of tags. #} + {% set suffix = taxonomy.name | capitalize %} +{% else %} + {% set suffix = "Lost?" %} +{% endif %} + +{# Return the final concatenated string. #} +{{ prefix ~ separator ~ suffix}} + +{% endmacro page_header %} diff --git a/templates/partials/header.html b/templates/partials/header.html index ed864e03f..6753abe83 100644 --- a/templates/partials/header.html +++ b/templates/partials/header.html @@ -4,30 +4,18 @@ {# Site title #} - {% set current_path = current_path | default(value="/") %} - {% if current_path == "/" %} -