Is there new latest Hugo generate RelPermalink change?

In my site had some different scheme design. So I build different configuration files for their environment. And generate the static web files with comman as below:

hugo -b /mist -e mist -d ./public/mist

But there strange the problem happend, the generate code for css had write the baseURL dobuble, like this: https://preview.hugo-next.eu.org/mist

<link rel=stylesheet href="/mist/mist/css/main.css?=1738675296">
<link rel=stylesheet type=text/css href="/mist/css/custom_style.css?=1738675296">

And the I write some debug code to print the css RelPermalink value when generate website code. The debug code append position is here

<!--style.html-->
{{ warnf "Relpermalink:%s, Permalink:%s." $css.RelPermalink $css.Permalink }}
{{ $unixHref := partial "_funs/add_unix_param.html" $css.RelPermalink }}
{{ warnf "unixHref:%s" $unixHref }}
<link rel="stylesheet" href="{{ $unixHref }}">

<!--add_unix_param.html-->
{{/** Add unix time end of link URL. **/}}
{{ $timeUnix := time.Now.Unix }}
{{ warnf "Add unix time end of link URL:%s" . }}
{{ $withTimeLink :=  printf "%s?=%d" . $timeUnix }}
{{ return $withTimeLink }}

source code is : hugo-theme-next/layouts/partials/head/styles.html at main · hugo-next/hugo-theme-next

then got the output message from console like this :

C:\Users\senhui.li\Documents\GitRepos\hugo-next-docs>hugo -e mist -b /mist -d ./public/mist
Start building sites …
hugo v0.143.0-ee48d9692af281180aea00645d86f3231a5231df+extended windows/amd64 BuildDate=2025-02-01T15:56:04Z VendorInfo=gohugoio

WARN  Relpermalink:/mist/css/main.css, Permalink:/mist/css/main.css.
WARN  Add unix time end of link URL:/mist/css/main.css
WARN  unixHref:/mist/css/main.css?=1738675296
WARN  Add unix time end of link URL:/css/custom_style.css
WARN  Add unix time end of link URL:/mist/js/main.js
WARN  Add unix time end of link URL:/mist/js/clipboard.js
WARN  Add unix time end of link URL:/mist/js/mermaid.js
WARN  Add unix time end of link URL:/mist/js/math.js
WARN  unixHref:/mist/css/main.css?=1738675298

                   | ZH-CN | EN-US
-------------------+-------+--------
  Pages            |   165 |   118
  Paginator pages  |     8 |     3
  Non-page files   |     8 |     8
  Static files     |   140 |   140
  Processed images |     0 |     0
  Aliases          |    63 |    46
  Cleaned          |     0 |     0

Total in 3397 ms

See the debug code output message seems not problem, why there the endly generate code with double baseURL in front to css and other resource get method.

The baseURL should include protocol, host, path (if any) and a trailing slash.

Because my website will deploy so many different domain, and then I would not write the full URL in baseURL params, only use the relative path to replace, and it can work fine in Hugo older version.

Sorry, I can’t understand this, why there endly code generate /mist/mist/css/main.css?=1738675296, not the expect code is /mist/css/main.css?=1738675296. All the relpermalink generat from resource methd were endly generat the same rule will be /mist/mist/xxxxx.

I remember that the older Hugo version would generate the right code is /mist/xxxx, but now the latest version could not same. So strange.

I also try your suggestion, but still got the error link generate like this:

hugo -e mist -b http://localhost:8080/mist/ -d ./public/mist
Start building sites …
hugo v0.143.0-ee48d9692af281180aea00645d86f3231a5231df+extended windows/amd64 BuildDate=2025-02-01T15:56:04Z VendorInfo=gohugoio

WARN  Relpermalink:/mist/css/main.css, Permalink:http://localhost:8080/mist/css/main.css.
WARN  Add unix time end of link URL:/mist/css/main.css
WARN  unixHref:/mist/css/main.css?=1738715820
WARN  Add unix time end of link URL:/css/custom_style.css
WARN  Add unix time end of link URL:/mist/js/main.js
WARN  Add unix time end of link URL:/mist/js/clipboard.js
WARN  Add unix time end of link URL:/mist/js/mermaid.js
WARN  Add unix time end of link URL:/mist/js/math.js
WARN  unixHref:/mist/css/main.css?=1738715822

                   | ZH-CN | EN-US
-------------------+-------+--------
  Pages            |   165 |   118
  Paginator pages  |     8 |     3
  Non-page files   |     8 |     8
  Static files     |   140 |   140
  Processed images |     0 |     0
  Aliases          |    63 |    46
  Cleaned          |     0 |     0

Endly result:

<link rel="stylesheet" href="http://localhost:8080/mist/mist/css/main.css?=1738715820">
<link rel="stylesheet" type="text/css" href="http://localhost:8080/mist/css/custom_style.css?=1738715820">

This works fine:

git clone --recurse-submodules https://github.com/hugo-next/hugo-theme-next
cd hugo-theme-next/exampleSite/
hugo server --themesDir ../..

I don’t know how to reproduce your problem.

Thanks for your support, not this theme’s exampleSite, you can clone the docs site as below:

git clone git@github.com:hugo-next/hugo-next-docs.git

cd hugo-next-docs
hugo -b /mist -e mist -d ./public/mist

And there you can found that the generate command in .github\workflows\deploy-dev-site.yml in job which name is build-deploy.

- name: Build Demo Sites
        run: |
              hugo --minify
              hugo -b /mist -e mist -d ./public/mist --minify
              hugo -b /muse -e muse -d ./public/muse --minify
              hugo -b /pisces -e pisces -d ./public/pisces --minify

Then why did you point me towards the theme repo? That just wasted 10 minutes of my time.

So sorry. That’s my mistake. when I post this problem the time I was trobule this issue in theme repo, but the replay step is complex, so forward the doc site will more easy to replay and found it.

You have enabled canonifyURLs.

https://gohugo.io/getting-started/configuration/#canonifyurls

See details before enabling this feature. Default is false .

https://gohugo.io/content-management/urls/#canonical-urls

This is a legacy configuration option, superseded by template functions and Markdown render hooks, and will likely be removed in a future release.

I strongly encourage you to disable that option. You can read more about it above, but its an imperfect, brute force approach that can affect content too. Don’t use it.

Having said that, the problem you are experiencing was unintentionally fixed in v0.143.1.

1 Like

Thank very much. :kissing_heart:

I try your suggestion and got the right result. Maybe I used it for many reasones but I can’t remember for why. And I will atten this for my develop theme work. :clap:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.