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.
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:
...
# Grav is Running!
## You have installed **Grav** successfully
![Unsplash](unsplash_1.jpg)
Congratulations!
...
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:
http://temp.dev/user/pages/01.home/unsplash_1.jpg
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.