Open CicoZhang opened 6 years ago
I used the following directory structure:
site
|--content
|--post
|--some-directory-heading
|--index.md
|--railroad-forest1.jpg
Images seem to be relative to the directory, so the image URL would simply be:
image = "railroad-forest1.jpg"
Perhaps you have a different use case?
Caused by https://github.com/appernetic/hugo-nederburg-theme/commit/0c596f19a3e79bf9465822d4e691b04477b5599d
I reverted the changes in my fork and it works. https://blog.tusharmishra.in/
Hm, to me the simplest solution seems to be @pks111607. Why revert changes then?
Maybe there is a need for better documentation. I will look in to this.
Just ran into the same issue with this theme.
Imho keeping the content and the images separated is the cleaner and also more intuitive way to go. With the current codebase the header image would be in the content/posts/
folder, whereas all images used inside the post would still be in static/
.
Therefore I'm also running a fork where the mentioned commit is reverted.
Netlify-cms (which I use for authoring content) defaults to a static directory.
Configuration options are listed here. Netlify-cms configuration
I ran into the same issue, which brought me here too.
I'm finding the exampleSite
to be broken at the moment, plus the live demo on themes.gohugo.io
seems to show the same problem: https://themes.gohugo.io/theme/hugo-nederburg-theme/
Ok, I will try to see if this would work.
In config settings
# Unmark to use post folder for images. Default is static folder.
#UsePostImgFolder = true
In templates image tags:
{{if isset .Site.Params "usepostimgfolder"}}data-background="{{ .Permalink }}{{ .Params.image }}{{ else }}data-background="{{ .Params.image | absURL }}"{{ end }}
This way it will work as before and if you want to have images in the post folder you unmark the seetings in the config file if you have it there.
Pushed!
So from now on just add usepostimgfolder = true to the config.toml file under [params] if you want a non standard set-up, eg use post folder for images. Simple as that :-)
Sounds good. Thanks for the fix :)
Thanks @appernetic! I just tried your changes with success.
It still does not seem to work on Hugo Themes and there is other weird issues with links there.
If I set the image URL like this:
It won't appear because the rendered URL is
http://localhost:1313/post/work5/img/portfolio/railroad-forest1.jpg
I think the right URL should be
http://localhost:1313/img/portfolio/railroad-forest1.jpg
.Maybe I do something wrongly?