Skip to content

Hugo Config option for blog URLs: avoid deprecation #2439

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

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

olleolleolle
Copy link
Contributor

@olleolleolle olleolleolle commented Aug 20, 2025

User description

Description

This PR avoids a warning emitted by latest Hugo at start of generating the website.

Motivation and Context

We want to follow current Hugo practices, to have a working website.

WARN  deprecated: the ":filename" permalink token was deprecated in Hugo 0.144.0 and will be removed in a future release. Use ":contentbasename" instead.

Update: hugo v0.125.4 is running in the GitHub Action. So that doesn't have support for that feature yet.

Now https://github.com/peaceiris/actions-hugo?tab=readme-ov-file#options CAN configure a newer one.

Update: I chose to update to latest Hugo in the jobs that required a newer one.

Types of changes

  • Change to the site (I have double-checked the Netlify deployment, and my changes look good)

Checklist

  • I have read the contributing document.
  • I have used hugo to render the site/docs locally and I am sure it works.

PR Type

Other


Description

  • Replace deprecated :filename with :contentbasename in Hugo permalinks

Diagram Walkthrough

flowchart LR
  A["Hugo Config"] -- "update permalink" --> B["Replace :filename"] -- "with" --> C[":contentbasename"]
Loading

File Walkthrough

Relevant files
Configuration changes
hugo.toml
Update Hugo permalink configuration                                           

website_and_docs/hugo.toml

  • Replace deprecated :filename token with :contentbasename in blog
    permalinks configuration
+1/-1     

    WARN  deprecated: the ":filename" permalink token was deprecated in Hugo 0.144.0 and will be removed in a future release. Use ":contentbasename" instead.
Copy link

netlify bot commented Aug 20, 2025

Deploy Preview for selenium-dev failed.

Name Link
🔨 Latest commit d050a10
🔍 Latest deploy log https://app.netlify.com/projects/selenium-dev/deploys/68a6ee97d944f500085f324f

Copy link
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

URL Compatibility

Changing from :filename to :contentbasename may alter generated URLs for posts where filename differs from slug or where multilingual/content structure affects basenames. Verify that existing links, redirects, and RSS entries remain valid.

blog = "/:section/:year/:contentbasename/"
# blog = "/:section/:year/:month/:day/:slug/"

Copy link
Contributor

qodo-merge-pro bot commented Aug 20, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Use a widely-supported token

Ensure the permalink token matches your Hugo version. In Hugo v0.55+ the
replacement for :filename is :slug or using :path components; :contentbasename
is only valid in newer Hugo versions. If your build runs on mixed or older
versions, use a safer, widely-supported token to avoid broken links.

website_and_docs/hugo.toml [30]

-blog = "/:section/:year/:contentbasename/"
+blog = "/:section/:year/:slug/"
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly raises a valid concern about Hugo version compatibility, as the :contentbasename token is newer and might not be supported in all build environments, proposing a safer alternative.

Medium
  • Update

Copy link
Member

@diemol diemol left a comment

Choose a reason for hiding this comment

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

It seems the build is failing.

@olleolleolle
Copy link
Contributor Author

In order to have a Hugo that supports the current way of expression, I set hugo-version to the current release in the CI jobs I could find. cc @diemol

Copy link
Member

@diemol diemol left a comment

Choose a reason for hiding this comment

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

Thank you for this.

However, there are other places where version 0.125.4 is set. Like the netlify.toml file.

@olleolleolle olleolleolle force-pushed the use-current-hugo-config-for-filename branch from e4cfddc to b2948d0 Compare August 21, 2025 09:56
@olleolleolle
Copy link
Contributor Author

I learned that there were a few more places. In situations like this, I often write a script/update_hugo_version shell script (perhaps in Ruby or something that is convenient for me) that updates all the places.

@diemol
Copy link
Member

diemol commented Aug 21, 2025

This is the error the Netlify build reports. I am not sure why the GitHub Actions build does not report the same.

12:02:50 PM: Start building sites …
12:02:50 PM: hugo v0.148.2-40c3d8233d4b123eff74725e5766fc6272f0a84d+extended linux/amd64 BuildDate=2025-07-27T12:43:24Z VendorInfo=gohugoio
12:02:50 PM: WARN  skipping template file "/opt/build/cache/hugo_cache/modules/filecache/modules/pkg/mod/github.com/google/[email protected]/layouts/_default/_markup/td-render-heading.html": unrecognized render hook template
12:02:53 PM: WARN  The "gist" shortcode was deprecated in v0.143.0 and will be removed in a future release. See https://gohugo.io/shortcodes/gist for instructions to create a replacement.
12:02:55 PM: WARN  The "twitter", "tweet", and "twitter_simple" shortcodes were deprecated in v0.142.0 and will be removed in a future release. Please use the "x" shortcode instead.
12:02:55 PM: ERROR deprecated: data.GetJSON was deprecated in Hugo v0.123.0 and subsequently removed. use resources.Get or resources.GetRemote with transform.Unmarshal.

@olleolleolle
Copy link
Contributor Author

@diemol There is a concept of “extended Hugo”, perhaps that has a different set of available commands/a different deprecation schedule. On my local macOS brew install, I got the warning about twitter, but not the error there.

@diemol
Copy link
Member

diemol commented Aug 21, 2025

I think the problem is this one:

12:02:55 PM: ERROR deprecated: data.GetJSON was deprecated in Hugo v0.123.0 and subsequently removed. use resources.Get or resources.GetRemote with transform.Unmarshal.

Yes, we use extended Hugo, because Docsy requires it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants