From 484d57f20a9cdc02dc30d833ce10fd4087663362 Mon Sep 17 00:00:00 2001 From: Sol <37932436+hydr0nium@users.noreply.github.com> Date: Thu, 11 Jul 2024 18:37:07 +0200 Subject: [PATCH] Require Hugo 0.120+, fix deprecation warnings (#502) * Fixed deprecated site.isServer param to hugo.isServer param * Also fixed another deprecated function for disqus * Updated README.md In the face of that we will update to 0.120 it would also be nice to update the README to reference the hugo.* file as the config instead of the config.* file. I also changed the description of the disqus feature to match the updated version of the code * Added checks for hugoVersion and disqus feature * Fixed accidental delete * Removed new line --- README.md | 39 +++++++++++++++++++++++++++--------- layouts/_default/baseof.html | 8 ++++++++ layouts/_default/single.html | 2 +- layouts/partials/disqus.html | 4 ++-- layouts/partials/footer.html | 7 ++++--- layouts/partials/head.html | 2 +- netlify.toml | 2 +- theme.toml | 2 +- 8 files changed, 47 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index cd5fdd91..d6fd30ab 100644 --- a/README.md +++ b/README.md @@ -87,13 +87,21 @@ Client side highlighting does not require pygments to be installed. This will us ### Disqus support -To use this feature, uncomment and fill out the `disqusShortname` parameter in `config.toml`. +To use this feature add your disqus shortname to the hugo.toml file like this: + +```toml +[services] + [services.disqus] + shortname = '' +``` + +For further reference see [hugo config](https://gohugo.io/methods/site/config/) ### Staticman support -Add *Staticman* configuration section in `config.toml` or `config.yaml` +Add *Staticman* configuration section in `hugo.toml` or `hugo.yaml` -Sample `config.toml` configuration +Sample `hugo.toml` configuration ``` [Params.staticman] @@ -134,26 +142,26 @@ comments: secret: "hsGjWtWHR4HK4pT7cUsWTArJdZDxxE2pkdg/ArwCguqYQrhuubjj3RS9C5qa8xu4cx/Y9EwHwAMEeXPCZbLR9eW1K9LshissvNcYFfC/b8KKb4deH4V1+oqJEk/JcoK6jp6Rr2nZV4rjDP9M7nunC3WR5UGwMIYb8kKhur9pAic=" ``` -If you *don't* have the section `[Params.staticman]` in `config.toml`, you *won't* need the section `reCaptcha` in `staticman.yml` +If you *don't* have the section `[Params.staticman]` in `hugo.toml`, you *won't* need the section `reCaptcha` in `staticman.yml` ### Site Disclaimer If you need to put a Disclaimer on your website (e.g. "My views are my own and not my employer's"), you can do so via the following: -* Uncomment and edit the `disclaimerText` parameter in `config.toml`. +* Uncomment and edit the `disclaimerText` parameter in `hugo.toml`. * If you need to adjust the disclaimer's styling, modify the declarations within the `footer div.disclaimer` selector in `static/css/main.css`. > The code for the disclaimer text is in `layouts/partials/footer.html`. Moving this code block to another partial file (or relocating it within `footer.html`) will require changes to the css selector in `main.css` as well. ### Google Analytics -To add Google Analytics, simply sign up to [Google Analytics](https://www.google.com/analytics/) to obtain your Google Tracking ID, and add this tracking ID to the `googleAnalytics` parameter in `config.toml`. +To add Google Analytics, simply sign up to [Google Analytics](https://www.google.com/analytics/) to obtain your Google Tracking ID, and add this tracking ID to the `googleAnalytics` parameter in `hugo.toml`. Note that the Google Analytics tracking code will only be inserted into the page when the site isn't served on Hugo's built-in server, to prevent tracking from local testing environments. ### Commit SHA on the footer -If the source of your site is in a Git repo, the SHA corresponding to the commit the site is built from can be shown on the footer. To do so, two site parameters `commit` has to be defined in the config file `config.toml`: +If the source of your site is in a Git repo, the SHA corresponding to the commit the site is built from can be shown on the footer. To do so, two site parameters `commit` has to be defined in the config file `hugo.toml`: ``` enableGitInfo = true @@ -166,7 +174,7 @@ See at [vincenttam/vincenttam.gitlab.io](https://gitlab.com/vincenttam/vincentta ### Multilingual To allow Beautiful Hugo to go multilingual, you need to define the languages -you want to use inside the `languages` parameter on `config.toml` file, also +you want to use inside the `languages` parameter on `hugo.toml` file, also redefining the content dir for each one. Check the `i18n/` folder to see all languages available. @@ -194,7 +202,7 @@ content/ content/ content/ With default settings, visiting to a website using Beautifulhugo connects also to remote services like google fonts or jsdelivr to embed fonts, js and other assets. -To avoid this, set the following param in config.toml: +To avoid this, set the following param in hugo.toml: ``` [Params] @@ -229,7 +237,7 @@ This is column 2. ### Social Media Icons -In order to show social media icons in the footer, add a section like this to your `config.yaml`. You can see the full list of supported social media sites in `data/beautifulhugo/social.toml`. +In order to show social media icons in the footer, add a section like this to your `hugo.yaml` or `hugo.toml`. You can see the full list of supported social media sites in `data/beautifulhugo/social.toml`. ```yaml author: @@ -238,6 +246,17 @@ author: github: halogenica/beautifulhugo twitter: username discord: 96VAXXvjCB + ... +``` + +```toml +[Author] + name = "Author Name" + website = "https://example.com" + github = "halogenica/beautifulhugo" + twitter = "username" + discord = "96VAXXvjCB" + ... ``` ## About diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index a67d0c4b..44f42463 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,3 +1,11 @@ +{{ if le hugo.Version "0.120.0" }} + {{ errorf "Please use Hugo version 0.120.0 or higher!" }} +{{ end }} + +{{ if not (eq .Site.DisqusShortname "") }} + {{ errorf "Your use of disqusShortname is deprecated by Hugo; Please reference the README.md for further instructions. This error message will be removed in the future because we are also using .Site.DisqusShortname for checking this." }} +{{ end }} + diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 7e4c43d1..27334c3b 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -76,7 +76,7 @@

{{ i18n "seeAlso" }}

{{ end }} - {{ if .Site.DisqusShortname }} + {{ if .Site.Config.Services.Disqus.Shortname }} {{ if .Site.Params.delayDisqus }}
diff --git a/layouts/partials/disqus.html b/layouts/partials/disqus.html index 80295259..f8948e78 100644 --- a/layouts/partials/disqus.html +++ b/layouts/partials/disqus.html @@ -1,7 +1,7 @@ {{ if (.Params.comments) | or (and (or (not (isset .Params "comments")) (eq .Params.comments nil)) (.Site.Params.comments)) }} - {{ if .Site.DisqusShortname }} + {{ if .Site.Config.Services.Disqus.Shortname }}
{{ template "_internal/disqus.html" . }}
{{ end }} -{{ end }} \ No newline at end of file +{{ end }} diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index ead747de..c6b85b8c 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -143,12 +143,13 @@ {{ end }} -{{ if and .Site.Params.delayDisqus .Site.DisqusShortname }} + +{{ if and .Site.Params.delayDisqus .Site.Config.Services.Disqus.Shortname }} - + {{ end }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index d33412dd..eb10481f 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -97,6 +97,6 @@ {{- end -}} {{- partial "head_custom.html" . }} -{{- if not .Site.IsServer -}} +{{- if not hugo.IsServer -}} {{ template "_internal/google_analytics.html" . }} {{- end -}} diff --git a/netlify.toml b/netlify.toml index 6727442e..702c78ac 100644 --- a/netlify.toml +++ b/netlify.toml @@ -3,6 +3,6 @@ command = "cd exampleSite && hugo --gc --themesDir ../.." [build.environment] - HUGO_VERSION = "0.120.1" + HUGO_VERSION = "0.120.0" HUGO_THEME = "repo" HUGO_BASEURL = "/" diff --git a/theme.toml b/theme.toml index db368388..7132d9c9 100644 --- a/theme.toml +++ b/theme.toml @@ -4,7 +4,7 @@ licenselink = "https://github.com/halogenica/Hugo-BeautifulHugo/blob/master/LICE description = "An adaptation of the Beautiful Jekyll theme" tags = ["blog", "company", "portfolio", "projects", "minimal", "responsive", "seo", "google analytics", "bootstrap", "disqus", "light", "syntax highlighting", "multilingual", "portfolio", "projects", "mobile", "technical"] features = ["blog", "company", "portfolio", "projects", "minimal", "responsive", "seo", "google analytics", "bootstrap", "disqus", "light", "syntax highlighting", "multilingual", "portfolio", "projects", "mobile", "technical"] -min_version = 0.48 +min_version = 0.120 [author] name = "halogenica"