Browse Source

Consistently override all page data in base template across all non-page views

Thibaud Colas 1 year ago
parent
commit
e47bc8b597

+ 2 - 0
bakerydemo/templates/404.html

@@ -2,6 +2,8 @@
 
 {% block title %}404 - Page not found{% endblock %}
 
+{% block search_description %}Sorry, this page could not be found{% endblock %}
+
 {% block body_class %}template-404{% endblock %}
 
 {% block content %}

+ 1 - 1
bakerydemo/templates/base.html

@@ -15,7 +15,7 @@
                 | {{ settings.base.SiteSettings.title_suffix }}
             {% endblock %}
         </title>
-        <meta name="description" content="{% if page.search_description %}{{ page.search_description }}{% endif %}">
+        <meta name="description" content="{% block search_description %}{% if page.search_description %}{{ page.search_description }}{% endif %}{% endblock %}">
         <meta name="viewport" content="width=device-width, initial-scale=1">
 
         {# Force all links in the live preview panel to be opened in a new tab #}

+ 6 - 0
bakerydemo/templates/base/preview/person.html

@@ -1,6 +1,12 @@
 {% extends "base.html" %}
 {% load wagtailimages_tags %}
 
+{% block title %}{{ object.first_name }} {{ object.last_name }} Preview{% endblock %}
+
+{% block search_description %}{{ object.job_title }}{% endblock %}
+
+{% block body_class %}template-preview-person{% endblock %}
+
 {% block content %}
     <div>
         {% image object.image fill-200x200-c100 class="blog__avatar" %}

+ 3 - 1
bakerydemo/templates/blog/blog_index_page.html

@@ -3,8 +3,10 @@
 
 {% if tag %}
     {% block title %}
-        Viewing all blog posts sorted by the tag {{ tag }}
+        {% if self.seo_title %}{{ self.seo_title }}{% else %}{{ self.title }}{% endif %}: {{ tag }}
     {% endblock %}
+
+    {% block search_description %}Viewing all blog posts sorted by the tag {{ tag }}{% endblock %}
 {% endif %}
 
 {% block content %}

+ 4 - 0
bakerydemo/templates/search/search_results.html

@@ -3,6 +3,10 @@
 
 {% block title %}Search{% if search_results %} results{% endif %}{% if search_query %} for “{{ search_query }}”{% endif %}{% endblock %}
 
+{% block search_description %}Search{% if search_results %} results{% endif %}{% if search_query %} for “{{ search_query }}”{% endif %}{% endblock %}
+
+{% block body_class %}template-search-results{% endblock %}
+
 {% block content %}
     <div class="container">
         <div class="row">