Skip to content

Commit

Permalink
Require Hugo 0.120+, fix deprecation warnings (#502)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
hydr0nium committed Jul 11, 2024
1 parent a48a6fa commit 484d57f
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 19 deletions.
39 changes: 29 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand All @@ -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.

Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
@@ -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 }}

<!DOCTYPE html>
<html lang="{{ .Lang }}" itemscope itemtype="http://schema.org/WebPage">
<head>
Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ <h4 class="see-also">{{ i18n "seeAlso" }}</h4>

{{ end }}

{{ if .Site.DisqusShortname }}
{{ if .Site.Config.Services.Disqus.Shortname }}
{{ if .Site.Params.delayDisqus }}
<div class="disqus-comments">
<button id="show-comments" class="btn btn-default" type="button">{{ i18n "show" }} <span class="disqus-comment-count" data-disqus-url="{{ trim .Permalink "/" }}">{{ i18n "comments" }}</span></button>
Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/disqus.html
Original file line number Diff line number Diff line change
@@ -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 }}
<div class="comments">
{{ template "_internal/disqus.html" . }}
</div>
{{ end }}
{{ end }}
{{ end }}
7 changes: 4 additions & 3 deletions layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,13 @@
<!-- End Piwik Code -->
{{ end }}

{{ if and .Site.Params.delayDisqus .Site.DisqusShortname }}

{{ if and .Site.Params.delayDisqus .Site.Config.Services.Disqus.Shortname }}
<!-- Delayed Disqus -->
<script type="text/javascript">
$(function(){
$('#show-comments').on('click', function(){
var disqus_shortname = '{{ .Site.DisqusShortname }}';
var disqus_shortname = '{{ .Site.Config.Services.Disqus.Shortname }}';

(function() {
var disqus = document.createElement('script');
Expand All @@ -163,7 +164,7 @@
});

</script>
<script id="dsq-count-scr" src="//{{ .Site.DisqusShortname }}.disqus.com/count.js" async></script>
<script id="dsq-count-scr" src="//{{ .Site.Config.Services.Disqus.Shortname }}.disqus.com/count.js" async></script>
<!-- End Delayed Disqus -->
{{ end }}

Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@
{{- end -}}

{{- partial "head_custom.html" . }}
{{- if not .Site.IsServer -}}
{{- if not hugo.IsServer -}}
{{ template "_internal/google_analytics.html" . }}
{{- end -}}
2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "/"
2 changes: 1 addition & 1 deletion theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 484d57f

Please sign in to comment.