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

Noob Q: add image to navigation section? #200

Closed
justvanrossum opened this issue Jan 28, 2025 · 3 comments
Closed

Noob Q: add image to navigation section? #200

justvanrossum opened this issue Jan 28, 2025 · 3 comments

Comments

@justvanrossum
Copy link

justvanrossum commented Jan 28, 2025

I would like to add a (small) image to the navigation section on each page. Should I add that to "base.njk"?

I'm trying this in base.njk:

		<header>
			<img src="/img/my-icon.svg">
			<a href="/" class="home-link">{{ metadata.title }}</a>

And I found that I can images to public/img/, but I can't seem to make the img src reference work. I bet I'm missing something super obvious.

Thanks in advance.

@justvanrossum
Copy link
Author

Worked around it by using <img eleventy:ignore src=...>.

@danburzo
Copy link

danburzo commented Jan 31, 2025

The unintuitive thing with the setup is that while there exists a public/img placeholder folder, and public is passed through to the output folder, you can’t really use <img src='/img/my-logo.svg'> because the eleventy-img HTML transform is enabled in the Eleventy config and quietly picks up and changes all <img> and <picture> tags. The plugin resolves root-relative image URLs (eg. /img/my-logo.svg) against the content folder, and fails quietly (due to the failOnError: false setting) when it doesn’t find content/img/my-logo-svg, but still alters the resulting URL as if it existed (I think).

My suggestion is to include in eleventy-base-blog this pattern: an SVG site-wide icon served from the public/img folder, to get a chance to document opting out of eleventy-img processing via eleventy:ignore.

@justvanrossum
Copy link
Author

Thanks Dan! I can now confidently strike my I bet I'm missing something super obvious. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants