From b04b1f5951386ccfec7feada1db655d253b9b6f0 Mon Sep 17 00:00:00 2001 From: Ivan Petkov Date: Tue, 7 Dec 2021 17:25:02 -0800 Subject: [PATCH] Add 404 page which fits the rest of the theme * Noting that (as of 0.14) zola does not pass much of a context when rendering the 404 page, so things like current URL/path aren't available * To work around this the `menu` macro has been split into `menu_for` which accepts a parameter for which item is active. * The previous macro continues to work as is, forwarding the results of figuring out which item is active to the new `menu_for` macro * The added 404 page will then use the `menu_for` macro and pass in a blank item --- templates/404.html | 16 ++++++++++++++++ templates/index.html | 2 ++ templates/macros/menu.html | 12 ++++++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 templates/404.html diff --git a/templates/404.html b/templates/404.html new file mode 100644 index 0000000..b913f2c --- /dev/null +++ b/templates/404.html @@ -0,0 +1,16 @@ +{% extends "index.html" %} + +{% block title %} +404 +{% endblock title %} + +{% block header_menu %} +{{ menu_macros::menu_for(config=config, current_item="") }} +{% endblock header_menu %} + +{% block content %} +
+

Lost?

+

This page does not exist.

+
+{% endblock content %} diff --git a/templates/index.html b/templates/index.html index 3d87910..ffa068a 100644 --- a/templates/index.html +++ b/templates/index.html @@ -45,7 +45,9 @@ + {% block header_menu %} {{ menu_macros::menu(config=config, current_path=current_path) }} + {% endblock header_menu %} {% endblock header %} diff --git a/templates/macros/menu.html b/templates/macros/menu.html index ca7fc67..58314e3 100644 --- a/templates/macros/menu.html +++ b/templates/macros/menu.html @@ -2,8 +2,6 @@ {%- if config.extra.menu_items %} {%- set menu_items = config.extra.menu_items -%} -