#Page assets inside page/__assets

2 messages · Page 1 of 1 (latest)

forest cloudBOT
#

Hi @queen socket. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Astro recommends storing all images to be optimized in the src/assets/ directory. This location is recognized by Astro as your new assets folder. However, it's optional and images can be stored anywhere, including alongside your content, if you prefer. Your images can be used by components (.astro, .mdx, and other UI frameworks) and in Markdown files source (https://docs.astro.build/en/guides/assets#move-your-images-to-srcassets).

However, if you're using the experimental astro:assets module, which will be enabled by default in [email protected], you might need to follow the Assets (Experimental) Guide (https://docs.astro.build/en/guides/assets/) to start using Astro’s new image solution source (https://docs.astro.build/en/guides/images).

If you're storing images in the public/ directory, they can be used by components and Markdown files. But, files in the /public directory are always served or copied as-is, with no processing. If you are using images outside of Markdown files, it's recommended that local images are kept in src/ when possible so that Astro can transform, optimize and bundle them source (https://docs.astro.build/en/guides/images#public).

If you're still having issues, it might be due to the relative path of the image. The src attribute is relative to the public folder. In Markdown, you can also use the !**** () notation. Here's an example:

---
// Access images in `public/images/`
---
<img src="/images/logo.png" />

source (https://docs.astro.build/en/guides/images#public)

If none of these solutions work, please provide more details about your project structure and the exact error message you're encountering.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: