adityatelange / hugo-PaperMod

A fast, clean, responsive Hugo theme.
https://adityatelange.github.io/hugo-PaperMod/
MIT License
10.26k stars 2.72k forks source link

[BUG] Deprecation of .Site.Social #1573

Closed ffha closed 2 weeks ago

ffha commented 3 months ago

Describe the bug

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.

adityatelange commented 3 months ago

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 commented 3 months ago

If you just want to make it disappear:

hugo.toml

[params]
    social = true

not sure about any side effects though. 🤷🏻

Cephra commented 3 months ago

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

ffha commented 3 months ago

OK, I will try.

ghost commented 3 months ago

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 commented 1 month ago

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 commented 1 month ago

@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 commented 1 month ago

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 commented 1 month ago

@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 commented 1 month ago

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 commented 1 month ago

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

Yorks0n commented 1 month ago

@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 }}
mtardy commented 3 weeks ago

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

jpmcb commented 3 weeks ago

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 commented 3 weeks ago

@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 commented 2 weeks ago

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