Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
Hi everyone,

I recently enabled the pretty URL option after setting up all of the required pages on my website and since doing so, have lost the images previously uploaded due to the image path now being incorrect.

For example, a page that was previously named 'our-story.php' (prior to enabling pretty URL), the image path was: images/temp/file.jpg. Now, since enabling pretty URL the Google Console is showing a 404 error on the images because the image path it is trying to find is; our-story/images/temp/file.jpg.

What is the best way to fix this?
- Dan
Relative links will display this problem and it has been discussed in the docs (https://docs.couchcms.com/concepts/pretty-urls.html).

The mentioned docs page suggests twp ways of making the relative links absolute -
1. Add a leading slash to all such links
2. Explicitly add the domain URL using <cms:show k_site_link /> with all such links.

There is, however, also a third option which could be the best one in your case - use HTML <base> tag in the <head> block of your template to specify the URL to be automatically added to all relative links e.g.
Code: Select all
<head>
    <base href = "https://www.yoursite.com" />
</head>
or
Code: Select all
<head>
    <base href = "<cms:show k_site_link />" />
</head>

Hope this helps.

Hi KK,

I was using relative links on a temporary page, stupid mistake and something I should have checked before creating this blog post - I did report the post to be considered for deletion. Might be a prompt for other people though.

I've added the domain URL <cms:show k_site_link /> to all links now, I think that's safer - albeit an absolute path but it doesn't really matter...

I also added a bath path to be safe too!

As always, I appreciate your support.

Kind regards.
- Dan
3 posts Page 1 of 1