hugo-theme-learn
hugo-theme-learn copied to clipboard
Changing the logo / custom logo broken on sub page in live view
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
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">
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 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
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!
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.
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).