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

[BUG] Deprecation of .Site.Social #1573

Closed
ffha opened this issue Aug 14, 2024 · 21 comments
Closed

[BUG] Deprecation of .Site.Social #1573

ffha opened this issue Aug 14, 2024 · 21 comments
Labels
bug Something isn't working

Comments

@ffha
Copy link

ffha commented Aug 14, 2024

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 ]: 9ea3bb0

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 ffha added the bug Something isn't working label Aug 14, 2024
@adityatelange
Copy link
Owner

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.

@Cephra
Copy link

Cephra commented Aug 19, 2024

If you just want to make it disappear:

hugo.toml

[params]
	social = true

not sure about any side effects though. 🤷🏻

@Cephra
Copy link

Cephra commented Aug 19, 2024

The reason you see the warning is because unless the social option is present, site.Social will be evaluated.

{{- with site.Params.social }}
{{- if reflect.IsMap . }}
{{- $twitterSite = .twitter }}
{{- end }}
{{- else }}
{{- with site.Social.twitter }}
{{- $twitterSite = . }}
{{- warnf "The social key in site configuration is deprecated. Use params.social.twitter instead." }}
{{- end }}
{{- end }}

&
{{- $facebookAdmin := "" }}
{{- with site.Params.social }}
{{- if reflect.IsMap . }}
{{- $facebookAdmin = .facebook_admin }}
{{- end }}
{{- else }}
{{- with site.Social.facebook_admin }}
{{- $facebookAdmin = . }}
{{- warnf "The social key in site configuration is deprecated. Use params.social.facebook_admin instead." }}
{{- end }}
{{- end }}

@ffha
Copy link
Author

ffha commented Aug 20, 2024

OK, I will try.

@ghost
Copy link

ghost commented Aug 24, 2024

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.

@fadihanna123
Copy link

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.

@jmooring
Copy link
Contributor

@adityatelange

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

@IanJempson
Copy link

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.

@ferdnyc
Copy link

ferdnyc commented Oct 17, 2024

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

@pchan2
Copy link

pchan2 commented Oct 20, 2024

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.

@adityatelange
Copy link
Owner

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

leomao added a commit to leomao/leomao.github.io that referenced this issue Oct 20, 2024
nicomo added a commit to nicomo/nicolasmorin that referenced this issue Oct 21, 2024
@Yorks0n
Copy link

Yorks0n commented Oct 22, 2024

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

contento added a commit to contento/hugo.quickstart that referenced this issue Oct 22, 2024
@mtardy
Copy link

mtardy commented Oct 25, 2024

Just for people to know, a PR is out to fix this #1620

penglezos added a commit to penglezos/penglezos.dev that referenced this issue Oct 25, 2024
gjanders added a commit to gjanders/gjanders.github.io that referenced this issue Oct 27, 2024
@jpmcb
Copy link

jpmcb commented Oct 28, 2024

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

@WinPoss
Copy link

WinPoss commented Nov 1, 2024

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

@adityatelange
Copy link
Owner

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

@penguinpal25
Copy link

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

@binamov
Copy link

binamov commented Dec 8, 2024

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

yo80106 added a commit to yo80106/hugo-theme-console that referenced this issue Dec 26, 2024
@flaviuvlaicu
Copy link

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

@Yorks0n
Copy link

Yorks0n commented Jan 3, 2025

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

@flaviuvlaicu
Copy link

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests