hugo-hero-theme icon indicating copy to clipboard operation
hugo-hero-theme copied to clipboard

Bug: Permalink and RelPermalink are generating malformed URLs in build output (theme-specific)

Open RobertAlbus opened this issue 3 years ago • 2 comments

Hugo version: 0.870+extended Problem exists in this theme, but not in a new theme when the relevant view templates and configs are ported in. Problem does not present itself when the site is viewed with hugo server but is present in build artifacts. It is present in other Hugo projects that use this theme.

themes/hugo-hero-theme/layouts/_default/baseof.html:16-17

 {{ $style := resources.Get "scss/style.scss" | toCSS (dict "targetPath" "css/style.css" "enableSourceMap" false) }}
  <link rel="stylesheet" href="{{ ($style | minify | fingerprint).RelPermalink }}">

This code, when using RelPermalink OR Permalink results in the following output:

#build output
  <link rel="stylesheet" href="/mywebsite.com/css/style.min.1cd4c[...].css">
#local server output
  <link rel="stylesheet" href="//localhost:1313/css/style.css">

expected output:

  <link rel="stylesheet" href="/css/style.min.1cd4c[...].css">
  # or
  <link rel="stylesheet" href="mywebsite.com/css/style.min.1cd4c[...].css">

Followup: When BaseURL = /, the build output results in a relative path

  <link rel="stylesheet" href="/css/style.min.1cd4c[...].css">

regardless of whether or not you use Permalink or RelPermalink

RobertAlbus avatar Aug 21 '21 21:08 RobertAlbus

@JugglerX Do you know why this might be happening?

kontralto-rob avatar Aug 28 '21 20:08 kontralto-rob

@RobertAlbus @kontralto-rob Here is what I tried

In the config.toml I have a baseURL = "www.example.com"

Running locally hugo serve I get <link rel="stylesheet" href="/css/style.min.f78f569c52930482d825f538adc06750cd316cb2520a7c9f09bc21535b65d628.css">

Building the site, running hugo I get <link rel="stylesheet" href="/www.example.com/css/style.min.4be821da6f580945734893eade9608940c6a2fa967507a70de1582d975493bc3.css">

If I change the baseURL to have a http or https prefix ie baseURL = "https://www.example.com/" It appears to fix it, I get <link rel="stylesheet" href="/css/style.min.4be821da6f580945734893eade9608940c6a2fa967507a70de1582d975493bc3.css">

JugglerX avatar Dec 26 '21 02:12 JugglerX