diff --git a/docs/advanced_topics/i18n.rst b/docs/advanced_topics/i18n.rst
index cfe94427fc..2c55520952 100644
--- a/docs/advanced_topics/i18n.rst
+++ b/docs/advanced_topics/i18n.rst
@@ -338,15 +338,25 @@ this into account.
{# make sure these are at the top of the file #}
{% load i18n wagtailcore_tags %}
- {% for translation in page.get_translations.live %}
- {% get_language_info for translation.locale.language_code as lang %}
-
- {{ lang.name_local }}
-
- {% endfor %}
+ {% if page %}
+ {% for translation in page.get_translations.live %}
+ {% get_language_info for translation.locale.language_code as lang %}
+
+ {{ lang.name_local }}
+
+ {% endfor %}
+ {% endif %}
Let's break this down:
+.. code-block:: html+Django
+
+ {% if page %}
+ ...
+ {% endif %}
+
+If this is part of a shared base template it may be used in situations where no page object is available, such as 404 error responses, so check that we have a page before proceeding.
+
.. code-block:: html+Django
{% for translation in page.get_translations.live %}