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

Wrong Permalink for resources in sites with baseURL with sub-path and canonifyURLs=true #5226

Closed
tadeboro opened this Issue Sep 18, 2018 · 8 comments

Comments

Projects
None yet
4 participants
@tadeboro

tadeboro commented Sep 18, 2018

hugo versions up to and including 0.42.2 used complete baseURL URL to create absolute permalinks for resources. Later versions use only host part of the config, which breaks sites that use path in the baseURL config.

The change that introduced the breakage is this: dea7167#diff-237662eaccac0a9acb0b64febadb5b5aR690

Official documentation on the other hand still states that baseURL should be (quote from docs): Hostname (and path) to the root.

Was this done on purpose and hugo does not support having path parts in the baseURL?

@kauron

This comment has been minimized.

kauron commented Oct 15, 2018

Hi, I'm also affected by this issue, is this going to be corrected or is it a feature?

@bep

This comment has been minimized.

Member

bep commented Nov 15, 2018

I have added a PR with some tests in this area. I expected them to fail, but they don't.

If this is still an issue, I need a concrete and failing test case to be able to fix this.

/cc @onedrawingperday

bep added a commit that referenced this issue Nov 15, 2018

@onedrawingperday

This comment has been minimized.

Contributor

onedrawingperday commented Nov 15, 2018

I need a concrete and failing test case to be able to fix this.

Here is the Hugo Bootstrap Premium Theme that was recently removed from the Hugo Themes Showcase due to missing CSS and JS assets.

In its templates this theme uses .Permalink for Hugo Pipes resources. Like over here

On themes.gohugo.io this theme's CSS would not load because .Permalink created a URL directly under themes.gohugo.io and not under themes.gohugo.io/theme/hugo-bootsrap-premium/

Steps to reproduce locally

git clone https://github.com/gohugoio/hugoThemes
git submodule add https://github.com/appernetic/hugo-bootstrap-premium.git
cd _script/
./generateThemeSite.sh http://localhost:1313 && hugo server -w=false -s hugoThemeSite/themeSite

As a fix we have been recommending that theme authors should use .RelPermalink for their Hugo Pipes Assets because .RelPermalink produces the correct URLs on the Hugo Themes Site.

CC / @digitalcraftsman

@bep bep removed the NeedsUserFeedback label Nov 15, 2018

@bep

This comment has been minimized.

Member

bep commented Nov 15, 2018

OK, I see what's going on here. This happens when canonifyurls = true is enabled. This is obviously a bug, but since the workaround(s) are easy (either don't use canonifyURLs or use RelPermalink) and I'm planning to eventually remove the "canonifyURLs" support, I will not spend time fixing this now. If others have time, feel free.

@digitalcraftsman @onedrawingperday I will update the theme builder script to disable canonifyurls for the demo sites.

@bep bep modified the milestones: v0.52, v0.53 Nov 15, 2018

bep added a commit to gohugoio/hugoThemes that referenced this issue Nov 15, 2018

@bep

This comment has been minimized.

Member

bep commented Nov 15, 2018

I may look at this later; I have turned off "canonifyURLs" on the theme site, but that may have other side effects.

@bep bep modified the milestones: v0.53, v0.52 Nov 15, 2018

@bep bep changed the title from Permalink function on resource ignores path part of the baseURL to Wrong Permalink for resources in sites with baseURL with sub-path and canonifyURLs=true Nov 15, 2018

bep added a commit to bep/hugo that referenced this issue Nov 15, 2018

bep added a commit to bep/hugo that referenced this issue Nov 15, 2018

bep added a commit to bep/hugo that referenced this issue Nov 15, 2018

bep added a commit to bep/hugo that referenced this issue Nov 15, 2018

@onedrawingperday

This comment has been minimized.

Contributor

onedrawingperday commented Nov 15, 2018

I may look at this later; I have turned off "canonifyURLs" on the theme site, but that may have other side effects.

Actually @bep it does cause problems. But since canonifyURLs is marked for removal I suppose that we have to fix these problems in the Themes Repository and also remove canonifyURLs from the Hugo Basic Example.

Now a theme like the Hugo Bootstrap Premium that you re-added with commit gohugoio/hugoThemes@2d9f912 works fine.

However themes that either have an Example Site like Hugo Fresh or rely on the Hugo Basic Example like Tale Hugo that have committed their Hugo Pipes Resources and use a ToCSS tranformation no longer have their demos generated due to the following ERROR

ERROR 2018/11/15 17:05:44 error: failed to transform resource: TOCSS: failed to transform "style.sass" (text/x-sass): this feature is not available in your current Hugo version

ERROR 2018/11/15 17:06:00 error: failed to transform resource: TOCSS: failed to transform "scss/tale.scss" (text/x-scss): this feature is not available in your current Hugo version
FAILED to create exampleSite for tale-hugo

It seems that now with canonifyURLs turned off in the Build Script Hugo cannot find the committed Hugo Pipes resources either with .RelPermalink or .Permalink used in the templates.

I don't know how to fix this and it seems like a catch 22.

Don't know if you have the time @bep maybe try executing the Build Script with these 2 themes that I mentioned above. May be canonifyURLs should be enabled in the Build Script again or maybe something else is going on.

@bep bep closed this in 5df2b79 Nov 15, 2018

@onedrawingperday

This comment has been minimized.

Contributor

onedrawingperday commented Nov 15, 2018

Ok. I just saw that as I posted the above comment you made a new commit that closed this issue.

I will take a look again and see if the problems I mentioned above are fixed.

@bep

This comment has been minimized.

Member

bep commented Nov 15, 2018

I have reverted my changes in the themes repo. Please don't make this issue into a bigger issue than it is.

  • This was a bug. It will be fixed with Hugo 0.52. Until then, the very valid workaround is to use .RelPermalink for CSS resources etc. (which I kind of prefer myself, but that is a matter of taste)
  • CanonifyURLs will not be removed before I implement an alternative.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment