Links to pages don't work now site is live

In the Panel, in a Writer Field, I’ve linked to some other pages on the website. The links work on my local computer, but now I’ve moved the site to the server the links no longer work.

Locally the link links to /about/our-vision page
but on the live site it links to a page called @/page/TUgFQB7JUzEzY4YU and the error page appears.

Any ideas?

Do you mean the same permalink does not resolve on live but does locally? Sure your content files are the same locally and on remote server?

Do you mean the same permalink does not resolve on live but does locally?

Yes.

Could this be because the “live” site is on a test subdomain? www.test.example.co.uk

If so, is it possible to get the permalinks (using the page Uuid) to actually link to the page?

Or do I need this extra code to get it to work?
$page->text()->permalinksToUrls()

I’ve still got this problem:

If I add links in a Writer Field to internal pages, the links do not work. Instead of linking for example to the /about/our-vision page, it links to the permalink @/page/TUgFQB7JUzEzY4YU.

Do I really need to add the permalinksToUrls() code to all my templates and snippets to get links to work?

$page->text()->permalinksToUrls()

(The site is now live and no longer on a subdomain)

permalinksToUrls() is certainly a solution that also avoids internal redirects for those links. This can improve the site performance, user experience and SEO performance.

However, the permalinks should work directly as well. You write that the links “don’t work”. Do you have more details on what doesn’t work? Do you get an error message, if so, which one?

I’m using the Writer Field and creating links to internal pages. In the website when I click the link I just get the 404 error page. This is because it is trying to link a page called

www.example.com/@/page/TUgFQB7JUzEzY4YU

Obviously this page doesn’t exist. So what do I do?

I really don’t want to have go through all my template and snippets adding permalinksToUrls() to every single field

I just want to be able to link to internal pages

Kirby has an internal route that redirects those requests to the real page URL.

Have you set up Kirby in a subfolder by any chance?

In a template, when I’m using a Writer Field do I have to use permalinksToUrls() to get links to work?

Or are you saying Kirby should be able to handle the link without this extra code?

Thanks for the additional details. The Force HTTPS option shouldn’t be related.

Since you wrote the content on your local machine, it could be that the UUID cache on the server is not yet complete. Kirby automatically updates it whenever a page is referenced, but it may not have made it to your production deployment.

You can regenerate the cache by calling Kirby\Uuid\Uuids::populate(); once. You can e.g. place this in a template temporarily, open the page and then remove the line again.

Yes. The @/page URLs should be redirected automatically (if the cache entry is present).

1 Like

Okay so that line of code needs to go in PHP tags

<?php Kirby\Uuid\Uuids::populate(); ?>

I’ve added it to one page, visited the page, then removed the code – and voila the links work!

Any idea what the problem was / why it didn’t work?

Thanks for your help

Yes, correct. Glad you got it working.

The permalinks (URLs that begin with /@/) require the UUID cache. This allows Kirby to quickly look up the actual page URL for each UUID. Without the cache, Kirby would have to search the whole page tree, which can cause a significant performance impact or even be used by attackers to make your site unavailable for a bit. That’s why the permalinks only work with the cache in place.

If you continue editing your site on the server via the Panel, Kirby will manage the UUID cache automatically.

It stopped working again.

Links from and to pages without “www” work.
Links from and to page with “www” do not work.

https://example.com/about to https://example.com/about/our-story – work
https://www.example.com/about to https://www.example.com/about/our-story– do not work

I’ve added <?php Kirby\Uuid\Uuids::populate(); ?> to my homepage template and visited not only https://example.com but also https://www.example.com.

The links now work regardless of www or no www.

Next questions are:

  • Why is the cache going wrong?
  • How can I avoid problems with the cache in the future?
  • Can I leave <?php Kirby\Uuid\Uuids::populate(); ?> on my homepage template?

Thanks