How to link to another page

In the Panel I have a writer field. I’ve added a link to another page in the website. In the content txt file I can see the link:

Page-intro: <p>Stock our branded products.<br><a href="/@/page/e2uM9I8ieVT5Mgf0">Info for wholesalers</a></p>

Here’s my template code

<?= $page->page_intro()->kirbytext()->permalinksToUrls()->smartypants() ?>

On my local dev site the link resolves to wholesale/wholesale-info. But on the staging site, on the server staging.example.com the link does not work, because there is not a page called e2uM9I8ieVT5Mgf0.

I don’t understand why this link is not working.

I have other links, for example: <a href=\"/@/page/Bq6DZRJ7Xzmvi3f4\">Our story</a> And the template <?= $block->text()->permalinksToUrls() ?> t hat are working.

Hmm, the only way I’ve got this to work is to log in to the staging panel. Remove the link and recreate the link to the page.

Am I going to have to do this to every link to every page I have created on my local dev site? Any why? Surely creating a link to another page should be easy?

Does this have something to do with site/cache ? I’ve deleted the local and staging cache and the link seems to work now.

If you have an old link on the staging site and use caching, then something like that could happen.

The thing is, a UUID for a model (page, file, user) is created when the model is created. So say you create a page on dev and link to it, then copy that page to staging and clear the cache, all should be fine.

An issue would happen if you create a page on dev, link to it on dev, then create the same page also on staging, but copy the page with the link to the page from dev to staging. At that point, the link would stop working. So you need to make sure to keep your stuff between local and staging in sync.

I don’t understand because the staging site was empty. So it wasn’t out of sync. I uploaded everything from my local dev to the staging site. Another few hours trying to link to a page…

You say ‘If you … use caching’ – is caching optional? Can I turn it off? Is it off by default (I haven’t turned it on in the config.php file)? I seem to remember having problems with caching before.

Is this referring to the site > caching folder?

Ok, was just an idea.

Yes.

Off by default, need to enable it in config, see docs

I’ve never turned caching on, on any of my Kirby sites – yet there are a lot of files in the

site > cache folder

Caching is not turned on in my config.php file – so what are these files?

Hi Mark,

Those are cached UUID values, for pages and files. They are created by default by Kirby.

You can switch this behaviour off, see this post for a bit more info:

Hi Mike

Thanks.

So cache for UUID is on by default, but off by default for pages.

Note that when you use UUIDS (by default they are turned on), but disable the cache for UUIDs, the performance of finding the right page for a UUID will suffer.

Hmm, think I’ll leave it on

Find the content txt file for wholesale/wholesale-info and look at the bottom of the file. There should be a UUID field. Does that have the UUID e2uM9I8ieVT5Mgf0 ? If not then something went wrong when you uploaded the website to the staging server. If you deleted and recreated the wholesale-info page on the staging server then it would have a different UUID to the local development version and would be the reason why it wasn’t working.

1 Like