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

Image in the post does not appear #34

Open
CicoZhang opened this issue Aug 17, 2018 · 11 comments
Open

Image in the post does not appear #34

CicoZhang opened this issue Aug 17, 2018 · 11 comments

Comments

@CicoZhang
Copy link

If I set the image URL like this:

image = "img/portfolio/railroad-forest1.jpg"

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?

@pks111607
Copy link

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?

@tmess567
Copy link

Caused by
0c596f1

I reverted the changes in my fork and it works.
https://blog.tusharmishra.in/

@brorio
Copy link

brorio commented Aug 23, 2018

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.

@fleaz
Copy link

fleaz commented Aug 26, 2018

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.

@tmess567
Copy link

Netlify-cms (which I use for authoring content) defaults to a static directory.

Configuration options are listed here.
Netlify-cms configuration

@scottyw
Copy link

scottyw commented Aug 29, 2018

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/

@appernetic
Copy link
Collaborator

appernetic commented Aug 31, 2018

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.

@appernetic
Copy link
Collaborator

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 :-)

@fleaz
Copy link

fleaz commented Aug 31, 2018

Sounds good. Thanks for the fix :)

@scottyw
Copy link

scottyw commented Sep 3, 2018

Thanks @appernetic! I just tried your changes with success.

@appernetic
Copy link
Collaborator

It still does not seem to work on Hugo Themes and there is other weird issues with links there.

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

6 participants