Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require Hugo 0.120+, fix deprecation warnings #502

Merged
merged 8 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = ''
Comment on lines +93 to +95
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[services]
[services.disqus]
shortname = ''
[services.disqus]
shortname = ''

Probably matches everything else, so not changing it here, but I really don't like this fake TOML nesting. Pretending TOML cares about indentation when it doesn't isn't helpful, IMO.

```

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 }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we error if Site.DisqusShortname is set? Similar to what I added in #481? Otherwise no one will know this was changed, it will just vanish from sites.

Copy link
Contributor Author

@hydr0nium hydr0nium Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I guess you can add that. Sounds good.

Edit: I can also add it if you have not time for that

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you'd like to, go ahead. Pretty distracted at the moment with catch up in various projects.

Copy link
Contributor Author

@hydr0nium hydr0nium Jul 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok you can not access the disqusShortname as you did with author due to the fact that it is a default value in .Site and will always be set by default to the empty string. As far as I see it there is not a proper way of checking if people use this deprecated feature without getting a warning because we need to use .Site.disqusShortname to actually check if people use it. I would say a compromise is that we do a check in a central location using .Site.disqusShortname with a warning that after sometime this check will be removed as .Site.disqusShortname is deprecated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My idea is to use this in the baseof.html

{{ 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 }}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable. I can move the other check (Site.Author) there too after it's in.

<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
Loading