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

How can I keep images in public folder, but use them within posts? #206

Open
marcosscriven opened this issue Mar 7, 2025 · 0 comments
Open

Comments

@marcosscriven
Copy link

marcosscriven commented Mar 7, 2025

Thanks for your work on 11ty! Amazing project, and works really nicely with Cloudflare Pages.

I see there's a directory in this project with a keep file: https://github.com/11ty/eleventy-base-blog/tree/main/public/img

If I put images in there, the only way I can access them from within a sub-directory of content, is something like this:

<img src="/../../../myimage.webp">

In the base blog as is, it seems to assume that images are either in the same dir as the post (such as https://github.com/11ty/eleventy-base-blog/tree/main/content/blog/fourthpost - so called 'relative'), or in the root of content (so called absolute)

If they are in _site/public (due to https://github.com/11ty/eleventy-base-blog/blob/main/eleventy.config.js#L18), the only way for the img tag to produce a valid path is with multiple ../ parent paths to break out of the nested content/ dir.

I asked in Discord #help, and I see there are a few similar questions/confusions around this, without a solution.

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

1 participant