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
When using a baseURL with path, links to static resources don't include path (but CSS, JS and page links do) #8078
Comments
This is not a bug. Please open a post on discourse.gohugo.io and add a template that shows, how the src-attribute for the image is built. There are ways to prepare the URL properly. Or you remove the starting slash from the referring tag (images/my-image.jpg and not /images/my-image.jgp). See https://discourse.gohugo.io/t/absurl-function-strips-path-when-using-baseurl-flag/5925 Have a look at page bundles to find a way to keep your post and images together, then it's even easier to reference them: https://gohugo.io/content-management/page-bundles/ |
@davidsneighbour Thanks for the fast response and sorry for my slow reply. I can actually replicate the problem though and created the following repository for you to showcase the problem: https://github.com/rickschubert/gohugo-base-url-with-path-issue
As can be seen from this example, it doesn't matter whether a
Please note that the problem can be fixed when using |
I've checked this on v0.81.0-DEV-ED3071B linux/amd64
|
I encountered the same issue even with v0.81.0-DEV. @pmatiash Why do you think it is working? As you can see in your post, it is not working correctly without Config:
Current result:
Expected result:
Otherwise, it does not work and the image is not shown. |
As mentioned in a forum thread I looked into render hook templates and what is working for me is using
But still, this should IMO work out of the box. |
hey @xoxys, why do you expect to see /blog in the relative path? |
Maybe I'm wrong, but I would expect it because that's what I get if I use e.g.
And that's the point that's confusing me... How/why does it work for you while it is definitely broken for me and @rickschubert? Markdown links and images are rendered to e.g. |
Problem stay with version 0.88.1
Link 1 exist , link 2 no . If I let canonifyurls set to TRUE , then there are problems like : with docdock theme SLIDE is not working anymore So I can see, it is HUGO himself who write the bad or good URL , with canonifyurls FALSE , subdomain is GONE And you say it is not a bug ? |
This issue should have been closed last year. See comments from @davidsneighbour. Not all themes are created equally. For example, some will fail dismally when serving from a subdirectory, while others perform perfectly. Please use the forum (https://discourse.gohugo.io) for questions and troubleshooting. We prefer to use GitHub for verified bugs and vetted enhancements. Thanks. |
Unbelievable that you cannot accept there is a bug !!!When triing to use canonifyURLs hugo crash with : canonifyURLs is an unexported field of struct type page.Site Check it yourself as follow , there is no THEME ,one markdown line and only one INTERNAL template used. Check it your self .Here is how :
4 cd to layout, create _default directory
N.B. So you CANNOT use CANONIFYURLS in THEME |
This is the list of site variables that you can access from a template:
|
High-Level Scenario
Given I use a baseURL with path, i.e.
https://mywebsite.net/blog
And I build my site using
hugo
orhugo server
Then CSS links start with
https://mywebsite.net/blog
And JS links start with
https://mywebsite.net/blog
And page links start with
https://mywebsite.net/blog
But links to static resources only start with "
https://mywebsite.net/
Lower Level description
Given I use a baseURL with path, i.e.
https://mywebsite.net/blog
And I have a markdown file
content/posts/my-first-post.md
And I have an image under
static/images/my-image.jpg
And the markdown file contains a link like this:
![](/images/my-image.jpg)
When I generate the site using
hugo
Then the image src attribute reads
https://mywebsite.net/images/my-image.jpg
But the image src attribute should read
https://mywebsite.net/blog/images/my-image.jpg
What version of Hugo are you using (
hugo version
)?Does this issue reproduce with the latest release?
Yes
The text was updated successfully, but these errors were encountered: