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

BUG: Incorrect image paths #32

Closed
VincentTam opened this issue Jul 4, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@VincentTam
Copy link
Contributor

commented Jul 4, 2019

Bug Report

Describe the bug

I tried building a demo site for this theme on Framagit: https://vincenttam.frama.io/fish-demo/blog/creating-a-new-theme/ with

baseurl = "https://vincenttam.frama.io/fish-demo/"

in config.toml. However, the images aren't rendered. Rendered HTML shows

<article class="mini-post">
      <section>
        
<a href="/fish-demo/blog/hugoisforlovers/" class="image featured">
  <img src="/img/2014/04/pic01.jpg" alt="Pic 1">
</a>


      </section>
      <header>
        <h1><a href="/fish-demo/blog/hugoisforlovers/">Getting Started with Hugo</a></h1>
        <time class="published" datetime="">April 2, 2014</time>
      </header>
    </article>

The src of the <img> is incorrect in case of GitHub/GitLab project pages. I'm not an expert in web design/development. You're going to be more proficient than me to fix this.

{{ if .Params.featured }}
<a href="{{ .RelPermalink }}" class="image featured">
<img src="/img/{{ if eq .Params.featuredpath "date" }}{{ .Page.Date.Format "2006/01" }}/{{ else }}{{ .Params.featuredpath }}{{ end }}{{ .Params.featured }}" alt="{{ .Params.featuredalt }}">
</a>
{{ end }}

Besides, I also get error on nav bar and page redirect after submitting Staticman comment. The images in the posts have incorrect URL's.

To Reproduce

  1. Use this theme on a GitHub/GitLab project pages
  2. See broken images

Expected behavior

Screenshot from 2019-07-04 13-26-34

Screenshots

Screenshot from 2019-07-04 13-23-12

Environment

@VincentTam VincentTam referenced this issue Jul 4, 2019

Closed

Remove Staticman #21

5 of 7 tasks complete
@pacollins

This comment has been minimized.

Copy link
Owner

commented Jul 4, 2019

That is an interesting bug I will have to look into. It is due to the URL being relative for multilingual, so I think Hugo might be parsing it odd? I'll check back.

@VincentTam

This comment has been minimized.

Copy link
Contributor Author

commented Jul 4, 2019

Thanks for reply. I should have said that the contents of the demo site are copied from exampleSite by

cp -r exampleSite/* LICENSE.md .
@pacollins

This comment has been minimized.

Copy link
Owner

commented Jul 4, 2019

On mobile, so I'm not certain on this, but I think this should solve it. It probably does not need the parenthesis around the path.Join, but I played it safe.

<img src="{{ (path.Join "img" (cond (eq .Params.featuredpath "date") (.Page.Date.Format "2006/01") (.Params.featuredpath)) .Params.featured) | relurl }}" alt="{{ .Params.featuredalt }}">

https://gohugo.io/functions/relurl/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.