From d8577538ca1d5bb8b73d15b075baef2ae22ded4b Mon Sep 17 00:00:00 2001 From: George Cushen Date: Thu, 19 Oct 2017 22:13:18 +0100 Subject: [PATCH] Improve 404 error page (Close #332) * Internationalize the page (string translation) * Add 3 new language variables: page_not_found, 404_recommendations, projects * Show recent talks and projects * For each content type, show most recent 5 items * Only show content headings if content exists for each type of content --- i18n/en.yaml | 11 +++++++++++ layouts/404.html | 38 ++++++++++++++++++++++++++++++++------ 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/i18n/en.yaml b/i18n/en.yaml index 44aa95be..366fdc12 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -127,3 +127,14 @@ - id: talks translation: Talks + +- id: projects + translation: Projects + +# Error 404 + +- id: page_not_found + translation: Page not found + +- id: 404_recommendations + translation: Perhaps you were looking for one of these? diff --git a/layouts/404.html b/layouts/404.html index 2779df79..889db3e9 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -2,22 +2,48 @@ {{ partial "navbar.html" . }}
-

Page not found

-

Maybe you were looking for one of these?

+

{{ i18n "page_not_found" }}

+

{{ i18n "404_recommendations" }}

-

Recent Posts

- {{ range last 20 (where .Data.Pages "Section" "=" "post") }} + {{ $posts_len := len (where .Site.RegularPages "Section" "post") }} + {{ if gt $posts_len 0 }} +

{{ i18n "posts" }}

+ {{ range last 5 (where .Site.RegularPages "Section" "post") }} {{ end }} + {{ end }} -

Recent Publications

- {{ range last 20 (where .Data.Pages "Section" "=" "publication") }} + {{ $pubs_len := len (where .Site.RegularPages "Section" "publication") }} + {{ if gt $pubs_len 0 }} +

{{ i18n "publications" }}

+ {{ range last 5 (where .Site.RegularPages "Section" "publication") }} {{ end }} + {{ end }} + + {{ $talks_len := len (where .Site.RegularPages "Section" "talk") }} + {{ if gt $talks_len 0 }} +

{{ i18n "talks" }}

+ {{ range last 5 (where .Site.RegularPages "Section" "talk") }} + + {{ end }} + {{ end }} + + {{ $projects_len := len (where .Site.RegularPages "Section" "project") }} + {{ if gt $projects_len 0 }} +

{{ i18n "projects" }}

+ {{ range last 5 (where .Site.RegularPages "Section" "project") }} + + {{ end }} + {{ end }}
{{ partial "footer_container.html" . }}