hugo-PaperMod: [BUG] Deprecation of .Site.Social

Describe the bug

  • Device/Os: MacOS
  • Type: Desktop
  • Browser and version [e.g. Chrome 86.0]:
  • Hugo Version: v0.131.0+extended
  • Theme Version [e.g. v4.0, master, or commit-id ]: 9ea3bb0e1f3a

Steps to reproduce the behavior: Using latest hugo version Run hugo server

Expected behavior: No Deprecation notice

Repo/Source where this issue can be reproduced: N/A

Screenshots N/A

Additional context .Site.Social was deprecated in Hugo v0.124.0 and will be removed in a future release. Use .Site.Params instead.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 14
  • Comments: 21 (4 by maintainers)

Commits related to this issue

Most upvoted comments

@adityatelange

Prior to v0.136.0 this emits a warning. With v0.136.0 and later this emits an error and fails the build.

If you just want to make it disappear:

hugo.toml

[params]
	social = true

not sure about any side effects though. 🤷🏻

@adityatelange

Prior to v0.136.0 this emits a warning. With v0.136.0 and later this emits an error and fails the build.

Finding difficult to keep up with Hugo’a pace of development. I work on a full time job with most saturdays working. Unable to keep aside some time for this at the moment. Very sorry.

Its a warning, chill WARN deprecated: .Site.Social was deprecated in Hugo v0.124.0 and will be removed in a future release. Use .Site.Params instead.

While it’s a warning that can be worked around, it means that the tutorial at https://gohugo.io/getting-started/quick-start/ doesn’t work. Following the tutorial steps of adding a post then running the server gives error messages. So the initial impression could be better.

I started the tutorial, thought this looks great, then within 15 minutes found myself dealing with an error message that told me what the problem was but not where the problem was.

@adityatelange Found how to fix this issue. Find opengraph.html and twitter_cards.html under themes/PaperMod/layouts/partials/templates/, then

# twitter_cards.html
{{ with site.Social.twitter -}}
# change to
{{ with .Site.Params.Social.twitter -}}

# opengraph.html
{{- with site.Social.facebook_admin }}
# change to
{{- with .Site.Params.Social.facebook_admin }}

I get the warning too. And I get the ways you can go to fix it. But it is a bug that will need to be addressed.

@IanJempson

I started the tutorial, thought this looks great, then within 15 minutes found myself dealing with an error message that told me what the problem was but not where the problem was.

Well, that behavior — that Hugo error messages frequently don’t include a file location where the error was encountered — is an issue for the Hugo developers (https://github.com/gohugoio/hugo/). The PaperMod theme creators have no control over the way Hugo displays error messages.

While it’s a warning that can be worked around, it means that the tutorial at https://gohugo.io/getting-started/quick-start/ doesn’t work. Following the tutorial steps of adding a post then running the server gives error messages. So the initial impression could be better.

That tutorial uses the Ananke theme, not the PaperMod theme. So if you hit the error while following that tutorial, then it wasn’t an issue with PaperMod, and it can’t be addressed in the PaperMod theme.

Upstream patches from Hugo and @jpmcb for templates are pushed. This should fix the issue.

Also ran into this on builds using hugo’s github action:

Run hugo --minify
  hugo --minify
  shell: /usr/bin/bash -e {0}
WARN  deprecated: site config key paginate was deprecated in Hugo v0.128.0 and will be removed in a future release. Use pagination.pagerSize instead.
Start building sites … 
hugo v0.136.5-46cccb021bc6425455f4eec093f5cc4a32f1d12c linux/amd64 BuildDate=2024-10-24T12:26:27Z VendorInfo=gohugoio

ERROR deprecated: .Site.Social was deprecated in Hugo v0.124.0 and will be removed in Hugo 0.137.0. Implement taxonomy 'social' or use .Site.Params.Social instead.
Total in 188 ms
Error: error building site: logged 1 error(s)

Finding difficult to keep up with Hugo’a pace of development. I work on a full time job with most saturdays working. Unable to keep aside some time for this at the moment. Very sorry.

@adityatelange - We appreciate all the incredible work that’s gone into this theme!! It’s been a big productivity boost for me personally. Please let the community know how we can continue to support you and this project!!

@adityatelange could you cut a new release please? This appears broken in v8.0

@adityatelange Found how to fix this issue. Find opengraph.html and twitter_cards.html under themes/PaperMod/layouts/partials/templates/, then

# twitter_cards.html
{{ with site.Social.twitter -}}
# change to
{{ with .Site.Params.Social.twitter -}}

# opengraph.html
{{- with site.Social.facebook_admin }}
# change to
{{- with .Site.Params.Social.facebook_admin }}

Yes, you are right, work. Thank you!

Just for people to know, a PR is out to fix this https://github.com/adityatelange/hugo-PaperMod/pull/1620

@adityatelange Found how to fix this issue. Find opengraph.html and twitter_cards.html under themes/PaperMod/layouts/partials/templates/, then

# twitter_cards.html
{{ with site.Social.twitter -}}
# change to
{{ with .Site.Params.Social.twitter -}}

# opengraph.html
{{- with site.Social.facebook_admin }}
# change to
{{- with .Site.Params.Social.facebook_admin }}

Thank you. That worked.

Can you please explain by changing these what does it actually do? Does it only remove the warning or solve the papermod theme issue?

The previous error was due to a change in syntax. This correction directly uses the appropriate writing method of the new version, thus solving the problem.

@adityatelange Found how to fix this issue. Find opengraph.html and twitter_cards.html under themes/PaperMod/layouts/partials/templates/, then

# twitter_cards.html
{{ with site.Social.twitter -}}
# change to
{{ with .Site.Params.Social.twitter -}}

# opengraph.html
{{- with site.Social.facebook_admin }}
# change to
{{- with .Site.Params.Social.facebook_admin }}

Thank you. That worked.

Hello, I fixed it, please see below my solution.

  1. To locate the problem, grep -r "site\.Social" -> credit or go to file path: /themes/ananke/layouts/partials/social-share.html
  2. Amend line 6 to {{ with site.Params.Social.twitter }}
  3. Run hugo server -D

Have a good day.

OK, I will try.