SEO-friendly image URLs

Hi @all!
Is there a way in Grav to make the image URLs more SEO-friendly?
Currently the generated URLs look somewhat like “src=”/grav/images/c/1/e/d/b/c1edbe4be099530736c1e9ec39be7f52ef941a54- mock1x.png"

Ideally the img would be in the same directory, as the containing webpage (e.g. “/products/mock1x.png”); and also would not have any hash in the URL.

Thanks a lot for any suggestions!

1 Like

If you were to not cache them, but access them directly, they would appear as you expect.

Could & should I use Grav in production without caching?
And could I even disable image caching? Grav docs state:

Image caching is also always on

Images are only cached when necessary, that is, when an action is applied to it by Grav. For example, with a file named unsplash_1.jpg in the user/pages/01.home/-folder:


{{['unsplash_1.jpg'].display('thumbnail').sepia().html() }}
{{ page.content }}


# Grav is Running!
## You have installed **Grav** successfully



In the first line of code in the template, we are making the image sepia-toned. This is done dynamically by Grav, so it must be cached to retain it’s changed appearance, and results in a path like:

However, in the page’s content, we are accessing the image directly (which we could also do in a template, by not adding any effects) and thus there is no reason for Grav to cache it. This results in a regular path:

So if you want to ensure SEO-friendly URLs, you’d need to do the processing yourself outside of Grav. I could imagine a system wherein the cache generates differently named URLs, exactly replicating paths from the user/pages/ structure, but it would potentially have to account for a variety of different configurations, which is why the current cache-mechanism is rather more fail-safe.

1 Like