I understand that I can access per $image->url() the physical path to any given image object. That’s fine and cool and great.
My problem is however, that I often resort my articles depending on personal aspects. When I resort my articles, the panel changes the file structure and therefore google and facebook scraper won’t find my image anymore. Because they cached the original image location. This results in a 404, which is always bad.
So I tested a bit there and here and could verify, that the SEO url (path without number dashes) for images works and redirects per http302 to the real path. Which is probably great. But how can I access the SEO url directly via kirby api? I’am looking for something like $image->permaurl() or $image->seourl().
I dont wan’t to do any hard string modifications on the physical file path itself, like removing the number dash stuff out of the path with regex or do some other nasty stuff. That will probably somewhere/somehow break.
Any ideas? I checked the docs but could not find anything usefull.
Humm, changing the structure isn’t really the best thing to do relating to SEO.
Do you manage broken links and bookmarks to articles with roots?
Well I just resort my articles in the same category, so the url remain the same.
For example URL “fruits/bananas”. It’s just in a other position in my article list. That works fine and great. Only my image urls break when I resort my stuff, because the article sorting number is hidden in the physical article path structure, for example “3-fruits/bananas/banana.jpg”, and when I move my articles it’s “4-fruits/bananas/banana.jpg”.
I won’t move articles in other categories, like “vegetables/bananas”. For sure, that would be very stupid for seo.
Ah, now i get it!
I read somewhere on GitHub (sorry, couldn’t find the link) that @bastianallgeier is implementing nice urls for files - so just wait a bit. I hope it’s not time-critical?
Oh those are great news.
Nah, it’s not time critical. I was just thinking about a better approch than my idea. Manual file path modification per regex or whatever sounds just wrong.
The main problem is actually just my somehow active facebook page for my webpage. Because images are disappearing in my shared links here and there and that looks broken for my users. But I’am aware of the problem and can manually fix those shares with the fb debugger tool, when I see them. Google image search does fix his self after a while, so I don’t really care about google.
Kirby supports redirection of page URLs to the original content directory now.
You can use the following if you need URLs that don’t change after sorting (but please note that this will require a redirection every time the file is being accessed):
echo $file->page()->url() . '/' . $file->filename();
This is not recommended.
Thanks for the reply. I will check it with fb scrapper. Maybe the extra request is not nice but the sorting feature is.