hugo-PaperMod icon indicating copy to clipboard operation
hugo-PaperMod copied to clipboard

[BUG] Deprecation of .Site.Social

Open ffha opened this issue 1 year ago • 9 comments
trafficstars

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.

ffha avatar Aug 14 '24 05:08 ffha

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.

adityatelange avatar Aug 17 '24 16:08 adityatelange

If you just want to make it disappear:

hugo.toml

[params]
	social = true

not sure about any side effects though. 🤷🏻

Cephra avatar Aug 19 '24 21:08 Cephra

The reason you see the warning is because unless the social option is present, site.Social will be evaluated. https://github.com/adityatelange/hugo-PaperMod/blob/58c4841c26325eaa788d9b13e65d5dfc95d9367c/layouts/partials/templates/twitter_cards.html#L21-L30 & https://github.com/adityatelange/hugo-PaperMod/blob/58c4841c26325eaa788d9b13e65d5dfc95d9367c/layouts/partials/templates/opengraph.html#L46-L56

Cephra avatar Aug 19 '24 21:08 Cephra

OK, I will try.

ffha avatar Aug 20 '24 12:08 ffha

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.

ghost avatar Aug 24 '24 14:08 ghost

If you just want to make it disappear:

hugo.toml

[params]
	social = true

not sure about any side effects though. 🤷🏻

Thanks! That worked for me.

fadihanna123 avatar Oct 15 '24 21:10 fadihanna123

@adityatelange

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

jmooring avatar Oct 16 '24 01:10 jmooring

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.

IanJempson avatar Oct 16 '24 21:10 IanJempson

@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.

ferdnyc avatar Oct 17 '24 04:10 ferdnyc

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.

pchan2 avatar Oct 20 '24 13:10 pchan2

@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.

adityatelange avatar Oct 20 '24 15:10 adityatelange

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

Yorks0n avatar Oct 22 '24 07:10 Yorks0n

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

mtardy avatar Oct 25 '24 15:10 mtardy

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

jpmcb avatar Oct 28 '24 17:10 jpmcb

@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!

WinPoss avatar Nov 01 '24 07:11 WinPoss

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

adityatelange avatar Nov 03 '24 09:11 adityatelange

@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.

i3hu avatar Nov 30 '24 09:11 i3hu

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

binamov avatar Dec 08 '24 22:12 binamov

@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?

flaviuvlaicu avatar Jan 03 '25 11:01 flaviuvlaicu

@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.

Yorks0n avatar Jan 03 '25 12:01 Yorks0n

Thanks

flaviuvlaicu avatar Jan 03 '25 13:01 flaviuvlaicu