#How to remove the hash which is automatically added to the Images

4 messages · Page 1 of 1 (latest)

exotic halo
#

here as we have attached an example we can see that that image after google.[hash].png , so is there any way we can define or keep our file path name.

vital grottoBOT
#

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

#

Astro automatically adds a hash to the filenames of images that are imported from the src/ directory or processed by its image optimization pipeline. This is by design, to enable cache busting and ensure users always get the latest version of an asset when it changes. The hash is not added for images served directly from the public/ directory—those retain their original filenames and paths.

There is no documented way in the official Astro documentation to remove or customize the hash for images processed by Astro’s asset pipeline. The filename structure is handled internally and is not configurable via the public API. The only way to keep your original file path and name (without a hash) is to place your images in the public/ directory and reference them by their relative path (e.g., /images/my-image.png). However, images in public/ are not processed or optimized by Astro’s image services—they are served as-is, without any transformations or optimizations applied by AstroHow to Resolve Images & Other Assets.

If you need image optimization and want to use the <Image /> or <Picture /> components, the hash in the filename is required and cannot be removed or customizedpropsToFilename().

Summary:

  • Images in src/ or processed by Astro will always have a hash in their filename.
  • To keep the original filename, place the image in public/, but you lose Astro’s image optimization features.
  • There is no supported way to remove or customize the hash for optimized images.
#

If you have a specific use case that requires custom filenames for optimized images, you may need to look for a custom build process outside of Astro’s built-in image handling.

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