Do not crash when taxonomy's header is not overriden

This commit is contained in:
southerntofu 2020-04-23 13:21:07 +02:00
parent 58a8677b85
commit 898078b75b
2 changed files with 7 additions and 3 deletions

View File

@ -174,7 +174,7 @@ The variables you can use in those templates are described on [zola docs](https:
**Note**: If your taxonomy template extends the theme's index.html, your site will crash if the template does not override the main block, as the one provided in index.html is intended for the homepage. This could be improved in the future, and patches are welcome!
**WARNING**: Taxonomies templates don't have a lang in Zola <= 10.1. If you are running Zola 10.1, please be sure to override the header block as well, or your site will crash.
**WARNING**: Taxonomies templates don't have a lang in Zola <= 10.1. If you are running Zola 10.1, please be sure to override the header block in your taxonomies templates or you will have a friendly error message displayed on your site (no crash).
**Note**: If you replace the theme's index.html entirely, please remember to include fallbacks for missing variables in taxonomies. These workarounds are marked "TAXONOMY" in the index.html so you can find them easily.

View File

@ -5,7 +5,7 @@
<head>
<meta charset="utf8">{# TAXONOMY: no section.title here #}
<title>{% block title %}{{ section.title|default(value=taxonomy.name) }}{% endblock %}</title>
{% if generate_rss %}<link rel="alternate" type="application/rss+xml" href="{{ widgets::i18n_url(path="rss.xml") }}">
{% if generate_rss %}<link rel="alternate" type="application/rss+xml" href="{% if lang %}{{ widgets::i18n_url(path="rss.xml") }}{% else %}{{ get_url(path="rss.xml")}}{% endif %}">
{% endif %}<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="{{ get_url(path="water." ~ config.extra.color ~ ".css") }}" type="text/css">
<link rel="stylesheet" href="{{ get_url(path="style.css") }}" type="text/css">
@ -16,7 +16,8 @@
<body{% if config.extra.max_width_for == "body" %} style="max-width: {{ config.extra.max_width }}"{% endif %}>
<header>
{% block header %}
{# TAXONOMY PROBLEM (not needed with Zola > 10.1) please override me or i will crash your site #}
{# TAXONOMY PROBLEM (not needed with Zola > 10.1) need to check if lang exists, do not display anything otherwise #}
{% if lang %}
{% if config.extra.header and config.extra.header != "disabled" %}{# TAXONOMY: no lang here #}
{% set header = get_page(path=widgets::i18n_path(path=config.extra.header, lang=lang)) %}
{{ header.content | markdown | safe }}
@ -30,6 +31,9 @@
{% elif config.extra.menu != "disabled" %}
<h2>Point config.extra.menu to a Markdown page and you will have a navigation menu</h2>
{% endif %}
{% else %}
<h3>Your zola version does not support translations in taxonomy templates. Please upgrade.</h3>
{% endif %}
{% endblock header %}
</header>
<main{% if config.extra.max_width_for == "main" %} style="max-width: {{ config.extra.max_width }}"{% endif %}>