This problems should apply to all kinds of structures but i will describe our case here:
We have a website with a blog section. It has several pages in the root level (one of them is the blog) and the posts are created as children of the blog page.
Some of the blog posts have PDF files (or other media) attached to them and they are linked in the markdown content of the post. The link looks like this for example: https://domain.org/user/pages/09.blog/175.post-name/file.pdf
Now it happens that we want to add a new page which should appear before the blog in the menu, so we sort the page to have the right numeric prefix. But that means the URL to the PDF file is now https://domain.org/user/pages/10.blog/175.post-name/file.pdf
Therefore the link in the markdown content of this page is broken because it is not being updated automatically when saving the new page.
Are we doing something wrong? Is there a way to prevent this or auto update such links?
@sque, You might try:
- Setting file change detection algorithm
hash in /user/config/system.yaml, or
$ bin/grav cache or 'Clear Cache` from Admin dashboard
I would expect
file to check for modified date or name change of the file, but that doesn’t seem to happen…
Hi @pamtbaau, thanks for you quick reply. I tried your suggestion but it did not help. I actually don’t find that surprising since i don’t see how this can be related to cache.
It is the actual page content which is not being updated, so i think that is not a cache problem. Or am i misunderstanding something?
@sque, You have saved the image inside the folder of the page, so in Markdown you would add
![Image title](myimage.jpg]. See Image Linking.
When Markdown is being processed it will be translated into
<img src="/user/pages/xx.mypage/myimage.jpg" ...> and the resulting HTML of the entire page will be cached.
After changing the folder name, or content, of the page, and Grav recognized the cache to be stale, the page will be processed again. A new url for the image will then be generated and cached again.
If you manually add an
<img src=""> element to the page using a hardcoded url, Grav will not change the url during processing.
Of course, you could also use an user/images (for example) folder, and link to that folder. That folder will not change when changing the name of the page’s folder.
Thanks a lot, i think the coin flipped now. Indeed we were including the files via absolute URL instead of referencing the media element of the page.
Doing so updates the reference accordingly.
Thanks a lot for the support!