From 4bc5529bc8bdb75bf707df94641a17c44a08aecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sat, 10 Feb 2024 23:22:35 +0100 Subject: [PATCH] theme: compatiblity for output format with Hugo 0.123 #771 --- exampleSite/config/_default/hugo.toml | 10 +++++----- .../content/basics/customization/_index.en.md | 20 +++++++++---------- .../content/basics/installation/_index.en.md | 2 +- .../content/basics/migration/_index.en.md | 12 ++++++----- hugo.toml | 12 +++++------ layouts/_default/rss.xml | 2 +- layouts/partials/header.html | 8 ++++---- layouts/partials/search.html | 4 ++-- layouts/partials/stylesheet.html | 6 +++--- layouts/partials/topbar/button/print.html | 2 +- static/js/search.js | 2 +- 11 files changed, 41 insertions(+), 39 deletions(-) diff --git a/exampleSite/config/_default/hugo.toml b/exampleSite/config/_default/hugo.toml index f86a8c4efa..e1c766bd6c 100644 --- a/exampleSite/config/_default/hugo.toml +++ b/exampleSite/config/_default/hugo.toml @@ -34,13 +34,13 @@ defaultContentLanguage = "en" title = "Hugo Relearn Theme" [outputs] - # add JSON to the home to support Lunr search; This is a mandatory setting + # add `json` to the home to support Lunr search; This is a mandatory setting # for the search functionality - # add PRINT to home, section and page to activate the feature to print whole + # add `print` to home, section and page to activate the feature to print whole # chapters - home = ["HTML", "RSS", "PRINT", "SEARCH", "SEARCHPAGE"] - section = ["HTML", "RSS", "PRINT"] - page = ["HTML", "RSS", "PRINT"] + home = ["html", "rss", "print", "search", "searchpage"] + section = ["html", "rss", "print"] + page = ["html", "rss", "print"] [markup] [markup.highlight] diff --git a/exampleSite/content/basics/customization/_index.en.md b/exampleSite/content/basics/customization/_index.en.md index 19c19f8c90..6987ea36ff 100644 --- a/exampleSite/content/basics/customization/_index.en.md +++ b/exampleSite/content/basics/customization/_index.en.md @@ -31,7 +31,7 @@ The theme will append an additional `index.html` to all page bundle links by def ```` {{% notice note %}} -If you want to use the search feature from the file system using an older installation of the theme make sure to change your outputformat for the homepage from the now deprecated `JSON` to `SEARCH` [as seen below](#activate-search). +If you want to use the search feature from the file system using an older installation of the theme make sure to change your outputformat for the homepage from the now deprecated `json` to `search` [as seen below](#activate-search). {{% /notice %}} ## Activate search @@ -40,18 +40,18 @@ If not already present, add the following lines in your `hugo.toml` file. ```toml [outputs] - home = ["HTML", "RSS", "SEARCH"] + home = ["html", "rss", "search"] ``` -This will generate a search index file at the root of your public folder ready to be consumed by the Lunr search library. Note that the `SEARCH` outputformat was named `JSON` in previous releases but was implemented differently. Although `JSON` still works, it is now deprecated. +This will generate a search index file at the root of your public folder ready to be consumed by the Lunr search library. Note that the `search` outputformat was named `json` in previous releases but was implemented differently. Although `json` still works, it is now deprecated. ### Activate dedicated search page -You can add a dedicated search page for your page by adding the `SEARCHPAGE` outputformat to your home page by adding the following lines in your `hugo.toml` file. This will cause Hugo to generate a new file `http://example.com/mysite/search.html`. +You can add a dedicated search page for your page by adding the `searchpage` outputformat to your home page by adding the following lines in your `hugo.toml` file. This will cause Hugo to generate a new file `http://example.com/mysite/search.html`. ```toml [outputs] - home = ["HTML", "RSS", "SEARCH", "SEARCHPAGE"] + home = ["html", "rss", "search", "searchpage"] ``` You can access this page by either clicking on the magnifier glass or by typing some search term and pressing `ENTER` inside of the menu's search box . @@ -66,13 +66,13 @@ To make sure, there is no duplicate content for any given URL of your project, r ## Activate print support -You can activate print support to add the capability to print whole chapters or even the complete site. Just add the `PRINT` output format to your home, section and page in your `hugo.toml` as seen below: +You can activate print support to add the capability to print whole chapters or even the complete site. Just add the `print` output format to your home, section and page in your `hugo.toml` as seen below: ```toml [outputs] - home = ["HTML", "RSS", "PRINT", "SEARCH"] - section = ["HTML", "RSS", "PRINT"] - page = ["HTML", "RSS", "PRINT"] + home = ["html", "rss", "print", "search"] + section = ["html", "rss", "print"] + page = ["html", "rss", "print"] ``` This will add a little printer icon in the top bar. It will switch the page to print preview when clicked. You can then send this page to the printer by using your browser's usual print functionality. @@ -80,7 +80,7 @@ This will add a little printer icon in the top bar. It will switch the page to p {{% notice note %}} The resulting URL will not be [configured ugly](https://gohugo.io/templates/output-formats/#configure-output-formats) in terms of [Hugo's URL handling](https://gohugo.io/content-management/urls/#ugly-urls) even if you've set `uglyURLs=true` in your `hugo.toml`. This is due to the fact that for one mime type only one suffix can be configured. -Nevertheless, if you're unhappy with the resulting URLs you can manually redefine `outputFormats.PRINT` in your own `hugo.toml` to your liking. +Nevertheless, if you're unhappy with the resulting URLs you can manually redefine `outputFormats.print` in your own `hugo.toml` to your liking. {{% /notice %}} ## Home Button Configuration diff --git a/exampleSite/content/basics/installation/_index.en.md b/exampleSite/content/basics/installation/_index.en.md index 30a2c6f498..c15c33f069 100644 --- a/exampleSite/content/basics/installation/_index.en.md +++ b/exampleSite/content/basics/installation/_index.en.md @@ -42,7 +42,7 @@ theme = "hugo-theme-relearn" # For search functionality [outputs] -home = [ "HTML", "RSS", "SEARCH"] +home = [ "html", "rss", "search"] ``` ## Create your first chapter page diff --git a/exampleSite/content/basics/migration/_index.en.md b/exampleSite/content/basics/migration/_index.en.md index 5c4c4f8665..1cc64fe587 100644 --- a/exampleSite/content/basics/migration/_index.en.md +++ b/exampleSite/content/basics/migration/_index.en.md @@ -46,6 +46,8 @@ This document shows you what's new in the latest release and flags it with one o - {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} Restored compatibility with Hugo versions {{% badge color="fuchsia" icon="fab fa-hackerrank" title=" " %}}0.121.0{{% /badge %}} or higher for the [`highlight` shortcode](shortcodes/highlight). This does not change the minimum required Hugo version. +- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} Restored compatibility with Hugo versions {{% badge color="fuchsia" icon="fab fa-hackerrank" title=" " %}}0.123.0{{% /badge %}} or higher for theme specific [output formats](basics/customization). This does not change the minimum required Hugo version. + --- ## 5.23.0 (2023-11-03) {#5230} @@ -422,7 +424,7 @@ This document shows you what's new in the latest release and flags it with one o - {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} This release introduces an additional dedicated search page. On this page, displayed search results have more space making it easier scanning thru large number of results. - To activate this feature, you need to [configure it](basics/customization#activate-dedicated-search-page) in your `hugo.toml` as a new outputformat `SEARCHPAGE` for the home page. If you don't configure it, no dedicated search page will be accessible and the theme works as before. + To activate this feature, you need to [configure it](basics/customization#activate-dedicated-search-page) in your `hugo.toml` as a new outputformat `searchpage` for the home page. If you don't configure it, no dedicated search page will be accessible and the theme works as before. You can access the search page by either clicking on the magnifier glass or pressing enter inside of the search box. @@ -460,7 +462,7 @@ This document shows you what's new in the latest release and flags it with one o - {{% badge style="note" title=" " %}}Change{{% /badge %}} [With the proper settings](basics/customization#serving-your-page-from-the-filesystem) in your `hugo.toml` your page is now servable from the local file system using `file://` URLs. - Please note that the searchbox will only work for this if you reconfigure your outputformat for the homepage in your `hugo.toml` from `JSON` to `SEARCH`. The now deprecated `JSON` outputformat still works as before, so there is no need to reconfigure your installation if it is only served from `http://` or `https://`. + Please note that the searchbox will only work for this if you reconfigure your outputformat for the homepage in your `hugo.toml` from `json` to `search`. The now deprecated `json` outputformat still works as before, so there is no need to reconfigure your installation if it is only served from `http://` or `https://`. - {{% badge style="note" title=" " %}}Change{{% /badge %}} The [`button` shortcode](shortcodes/button) has a new parameter `target` to set the destination frame/window for the URL to open. If not given, it defaults to a new window/tab for external URLs or is not set at all for internal URLs. Previously even internal URLs where opened in a new window/tab. @@ -494,12 +496,12 @@ This document shows you what's new in the latest release and flags it with one o - {{% badge style="note" title=" " %}}Change{{% /badge %}} Because the print preview URLs were non deterministic for normal pages in comparison to page bundles, this is now changed. Each print preview is now accessible by adding a `index.print.html` to the default URL. - You can revert this behavior by overwriting the PRINT output format setting in your `hugo.toml`to: + You can revert this behavior by overwriting the `print` output format setting in your `hugo.toml`to: ````toml [outputFormats] - [outputFormats.PRINT] - name= "PRINT" + [outputFormats.print] + name= "print" baseName = "index" path = "_print" isHTML = true diff --git a/hugo.toml b/hugo.toml index 2547052332..9886305177 100644 --- a/hugo.toml +++ b/hugo.toml @@ -7,24 +7,24 @@ suffixes = ["js"] [outputFormats] - [outputFormats.PRINT] - name= "PRINT" + [outputFormats.print] + name= "print" baseName = "index.print" isHTML = true mediaType = 'text/html' permalinkable = false noUgly = true - [outputFormats.SEARCH] - name= "SEARCH" + [outputFormats.search] + name= "search" baseName = "index.search" isPlainText = true mediaType = 'text/javascript' permalinkable = false noUgly = true - [outputFormats.SEARCHPAGE] - name= "SEARCHPAGE" + [outputFormats.searchpage] + name= "searchpage" baseName = "search" isHTML = true mediaType = 'text/html' diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml index 50868237cf..4319aa1ae2 100644 --- a/layouts/_default/rss.xml +++ b/layouts/_default/rss.xml @@ -34,7 +34,7 @@ {{ . }}{{ with $authorName }} ({{ . }}){{ end }}{{ end }}{{ with .Site.Copyright }} {{ . }}{{ end }}{{ if not .Date.IsZero }} {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}{{ end }} - {{- with .OutputFormats.Get "RSS" }} + {{- with .OutputFormats.Get "rss" }} {{ printf "" ( partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true)) .MediaType | safeHTML }} {{- end -}} {{- range $pages }} diff --git a/layouts/partials/header.html b/layouts/partials/header.html index ec0928ad57..96b3440779 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -49,8 +49,8 @@ {{- if eq .Rel "canonical" }} {{ (printf $link (partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true "basename" $basename)) .Rel .MediaType.Type ($title | htmlEscape)) | safeHTML }} {{- else if eq $outputFormat "searchpage" }} - {{- else if eq .Name "SEARCHPAGE" }} - {{- else if and (ne .Name "JSON") (ne .Name "SEARCH") }} + {{- else if eq .Name "searchpage" }} + {{- else if and (ne .Name "json") (ne .Name "search") }} {{ (printf $link (partial "relLangPrettyUglyURL.hugo" (dict "to" .)) .Rel .MediaType.Type ($title | htmlEscape)) | safeHTML }} {{- end }} {{- end }} @@ -58,8 +58,8 @@ {{- if and (ne .Site.Params.disableSeoHiddenPages true) (ne .Site.Params.disableSearchHiddenPages true) }} {{- range .AlternativeOutputFormats }} - {{- if eq .Name "SEARCHPAGE" }} - {{- else if eq .Name "JSON" }} + {{- if eq .Name "searchpage" }} + {{- else if eq .Name "json" }} {{ (printf $link (.Permalink | relURL) .Rel .MediaType.Type ($title | htmlEscape)) | safeHTML }} {{- end }} {{- end }} diff --git a/layouts/partials/search.html b/layouts/partials/search.html index 46ad875e29..429caee47b 100644 --- a/layouts/partials/search.html +++ b/layouts/partials/search.html @@ -1,6 +1,6 @@ {{- $link := "" }} - {{- if or (.Site.Home.OutputFormats.Get "JSON") (.Site.Home.OutputFormats.Get "SEARCH") }} - {{- with .Site.Home.OutputFormats.Get "SEARCHPAGE" }} + {{- if or (.Site.Home.OutputFormats.Get "json") (.Site.Home.OutputFormats.Get "search") }} + {{- with .Site.Home.OutputFormats.Get "searchpage" }} {{- $link = partial "relLangPrettyUglyURL.hugo" (dict "to" .) }} {{- end }} {{- end }} diff --git a/layouts/partials/stylesheet.html b/layouts/partials/stylesheet.html index 03f292b901..fe04fca021 100644 --- a/layouts/partials/stylesheet.html +++ b/layouts/partials/stylesheet.html @@ -31,11 +31,11 @@