hugo-theme-learn icon indicating copy to clipboard operation
hugo-theme-learn copied to clipboard

Changing the logo / custom logo broken on sub page in live view

Open r4dh4l opened this issue 6 years ago • 6 comments

Hi,

sorry I don't know if this is a bug or a mistake on my side but following https://themes.gohugo.io//theme/hugo-theme-learn/en/basics/style-customization/ the logo I want to add is not recognized.

I've added

  • MyHugoWebsite/layouts/partials/logo.html
  • MyHugoWebsite/static/media/mylogo.jpg

and added in MyHugoWebsite/layouts/partials/logo.html:

<img src="../../static/media/mylogo.jpg" alt="mylogo.jpg">

http://localhost:1313/ just lists "mylogo.jpg". Did I miss something?

My hugo version:

$ snap run hugo version
Hugo Static Site Generator v0.51 linux/amd64 BuildDate: 2018-11-07T12:22:45Z

r4dh4l avatar Dec 08 '18 23:12 r4dh4l

The relative path you have there is incorrect. Once built, there isn't a folder called 'static'. <img src="/media/mylogo.jpg" alt="mylogo.jpg">

coliff avatar Dec 12 '18 16:12 coliff

Hi,

I think you need to remove /static from the src attribute of the img tag.

Start the server (hugo server -D), and check if you are able too see the picture at http://localhost:1313/media/mylogo.jpg . If you do, using <img src="media/mylogo.jpg" alt="mylogo.jpg"> or <img src="../../media/mylogo.jpg" alt="mylogo.jpg"> shoud display your logo :-)

pdelaby avatar Dec 12 '18 16:12 pdelaby

@pdelaby funny coincidence. this issue had been open for 4 days and then we both replied within 14 seconds of each other saying the same thing. :-D

coliff avatar Dec 12 '18 16:12 coliff

Thx @coliff and @pdelaby !

<img src="/media/mylogo.jpg" alt="mylogo.jpg"> works.

Maybe I was confused by https://themes.gohugo.io//theme/hugo-theme-learn/en/basics/style-customization/ saying

Create a new file in layouts/partials/ named logo.html. Then write any HTML you want. You could use an img HTML tag and reference an image created under the static folder, or you could paste a SVG definition!

r4dh4l avatar Dec 12 '18 19:12 r4dh4l

Start the server (hugo server -D), and check if you are able too see the picture at http://localhost:1313/media/mylogo.jpg . If you do, using <img src="media/mylogo.jpg" alt="mylogo.jpg"> or <img src="../../media/mylogo.jpg" alt="mylogo.jpg"> shoud display your logo :-)

I just noticed: In case of using the offline view/live server view this only works on the start. Clicking on any sub page the alt text only is listed.

r4dh4l avatar Oct 25 '20 23:10 r4dh4l

I am having the same problem with the sub page not showing the image. But for me this happens both on live view and when I publish it to GitHub. Also, I have to source the image differently for viewing it in live view and on GitHub. For live view, this works for src="media/image.jpg" , but to view it on GitHub: src="/media/image.jpg" (note: to publish to GitHub, I copy the contents of the public folder to docs folder).

hughcross avatar Mar 25 '21 00:03 hughcross