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

RelPermalink incorrect for scss in combination with canonifyURLs #12774

Open
caspermeijn opened this issue Aug 16, 2024 · 2 comments
Open

RelPermalink incorrect for scss in combination with canonifyURLs #12774

caspermeijn opened this issue Aug 16, 2024 · 2 comments

Comments

@caspermeijn
Copy link

The RelPermalink of scss file converted using toCSS is incorrect when the baseURL has a path and canonifyURLs is enabled.

I already found #4733 which suggests removing support of canonifyURLs. I will disable canonifyURLs in my configuration to work around this problem.

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.132.1-1bde700dfc0770bb11eb8445aff1ab5abdccb46e+extended linux/amd64 BuildDate=2024-08-13T10:10:10Z VendorInfo=gohugoio

Does this issue reproduce with the latest release?

Yes, it does happen with v0.132.2.

Reproducable

I created a test that can reproduce the problem. This test fails when added to the hugo codebase.

func TestRelParmalink(t *testing.T) {

	files := `
-- hugo.toml --
canonifyURLs = true
baseURL = 'https://caspermeijn.github.io/receptenboek/'
-- assets/scss/main.scss --
h2 {
	color: blue;
}
-- layouts/index.html --
{{ $cssOpts := (dict "targetPath" "css/gochowdown.css" ) }}
{{ $r := resources.Get "scss/main.scss" |  toCSS $cssOpts }}
<link rel="stylesheet" href="{{ $r.RelPermalink }}">
		`

	b := hugolib.NewIntegrationTestBuilder(
		hugolib.IntegrationTestConfig{
			T:           t,
			TxtarString: files,
			NeedsOsFS:   true,
		}).Build()

	b.AssertFileContent("public/index.html", "<link rel=\"stylesheet\" href=\"https://caspermeijn.github.io/receptenboek/css/gochowdown.css\">")
}
@jmooring
Copy link
Member

In the example above...

Expected URL to stylesheet:

https://caspermeijn.github.io/receptenboek/css/gochowdown.css

Actual URL to stylesheet:

https://caspermeijn.github.io/receptenboek/receptenboek/css/gochowdown.css

Instead of fixing this, can we instead deprecate canonifyURLs per #4733? In the documentation we've been discouraging its use for a quite a while:
https://gohugo.io/content-management/urls/#canonical-urls

@caspermeijn
Copy link
Author

Seems a valid solution to me. I was using canonifyURLs because it came with the example inside a theme. I didn't know it was discouraged.

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

No branches or pull requests

2 participants