Links in frontend rendering wrong (@/page/nf9849... or page://nf9849...)

Suddenly (after editing my site for 1 or 2 hours) the links that I set in the editor get rendered totally wrong in the frontend. The links are not resolved to the “nice” URL, the are resolved to something like https://www.domain.com/@/page/k55n6xfncE6Eix07 or when used in the image module it resolves to page://k55n6xfncE6Eix07

Is there anything, that I could “delete” to clear the cache? (I already deleted everything inside /site/cache/ but to no avail).

Or is there something else, that I can do?

(it is really strange, that this just appeared after some time.)

Those links might look weird, but they are actually permalinks and should work. If you want to get rid of them, you can call permalinksToUrls() on the field, see $field->permalinksToUrls() | Kirby CMS

@texnixe thank you very much for the answer. I’m actually just rendering a layout in templates\default.php (with the layouts.php snippet from the starterkit) with this code:

<?php snippet('layouts', ['field' => $page->layout()])  ?>

So I changed it to

<?php snippet('layouts', ['field' => $page->layout()->permalinksToUrls()])  ?>

And I have this blueprints\pages\default.yml

title: Simple Page

icon: 📝

status:
  draft: true
  unlisted:
    label: Hidden Page
    text: The page is not listed in the main menu
  listed:
    label: Menu Page
    text: The page is listed in the main menu

columns:
  main:
    width: 2/3
    sections:
      content:
        type: fields
        fields:
          layout:
            label: Layout
            type: layout
            layouts:
              - "1/1"
              - "1/2, 1/2"
              - "1/3, 1/3, 1/3"
              - "1/3, 2/3"
              - "2/3, 1/3"
              - "1/2, 1/4, 1/4"
              - "1/4, 1/4, 1/2"
              - "1/4, 1/4, 1/4, 1/4"
  sidebar:
    width: 1/3
    sections:
     
      pages:
        type: pages
        label: Unterseiten
        template: default
      
      files:
        label: Dateien
        type: files


But the links are still not working. :melting_face:

you can check the outcome here (the text links beneath the images have the wrong URLs): Unsere Angebote | Mahling Gase: Propangas, CO2, Grillgeräte, Heizgeräte, techn. Gase & Campingartikel

I’m really happy about every little hint that I could check. :crossed_fingers:

E D I T
I did a completely fresh install from the starterkit-main (version 4.6.1) about 3 mins ago, inserted a text link on the about page with the same outcome: Mægazine | About us (Could this be a bug in the starterkit?)

Sorry for the later reply, been out all day. Hm, for some reason the permalinks do not resolve, while they should actually redirect to the “proper” page url. Could you check if the referenced pages really have that UUID stored in the content files?

(Don’t worry @texnixe – it was a really nice sunny day :sun_with_face: I was also out)

The link should point to the page “home”. This is what content\home\home.txt looks like:

Title: Home

----

Headline: Welcome to Kirby's Starterkit

----

Subheadline: A fully documented example project

----

Uuid: wljMYhm0m3e9QOwC

So yes, the Uuid is the same as in the link (page with text link for reference).

Does the uuid cache exists in site/cache/yourdomain/uuid?

Otherwise, try to populate it with a little script:

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

Yes, they do exists in the cache folder:

Ok, I know why the starterkit does not work, the url resolves to https://formlos.dev/ and not https://formlos.dev/starterkit-main... because you put it into a subfolder. To make this work, you would have to set the url in your config.php

Looks like it’s the same issue on the other site, which seems to live in a subfolder called neu.

Ah Ok, thanks!

So i put this im my site/config/config.php, but it still doesn’t resolve (I also deleted the whole cache-forlder for the domain)

return [
    'debug' => true,
    'yaml.handler' => 'symfony', // already makes use of the more modern Symfony YAML parser: https://getkirby.com/docs/reference/system/options/yaml (will become the default in a future Kirby version),
    'panel' =>[
        'install' => true
    ],
    'url' => 'https://formlos.dev/starterkit-main/'
];

Hm, then maybe they only work with those subfolders if you resolve them via permalinksToUrls(). Maybe to get around this issue, better use subdomains like neu.formlos.dev etc. instead of those subfolders, and point those subdomains to those folders. Then everythign should work as expected.

Ok thanks again! I did a quick new install in a subdomain (Mægazine | About us): the „ugly“ links are still rendered in the HTML but if clicked, they resolve to the right page (as you explained :+1:).

But now I’m a little bit confused: what is the right way to insert „pretty“ links in the layout builder, when using the text-block? This is how I do it (and I assume this is what clients also would do):
I just select the text for the link and click on the link-icon [:link:] and the change the dropdown from „url“ to „page“:

In my understanding this would mean, in all kirby installations, the links look „ugly“ when using the „layouts“ block. (This is something, which I can hardly imagine). So maybe I’m doing something wrong? (Sidenote: I just „tried“ kirby via zone1.trykirby.com with the same result: „ugly“ URLs when using the layout builder on the microsite example)

Thus, I tried the solution you mentioned earlier. But if I change the code in site/templates/about.php from

<?php snippet('layouts', ['field' => $page->layout()])  ?>

to

<?php snippet('layouts', ['field' => $page->layout()->permalinksToUrls()])  ?>

then the whole layout block is not rendered at all :person_shrugging:.

So how would I go about that? (Sorry to bother again, but once the mentioned new website is finally finished, I really want to have „nice“ and SEO-friendly readable URLs inside text links on the clients website.)

It doesn’t make sense to call the method on the layout field, but you would make a copy of the original text.php block snippet in /site/snippets/blocks/ and call it there on the text field, so instead of

<?= $block->text();

it would then become

<?= $block->text()->permalinksToUrls();

Thank you @texnixe so much for the continous support – this is the solution!

(Although it’s kind of strange that the links are not converted to speaking SEO URLs by default. Especially because in the navigation and image block the conversion works “automatically”. I could imagine that this is a useful change for the next version. So that all links are converted automatically. Of course, this also works directly without having to enter any absolute paths in config.php).

Never mind, this was a caching problem I think :person_facepalming:

wrong question/answer

I was a little bit to fast with the solution :melting_face: The solution you mentioned works for the text block. But it doesn’t work for links inside the list-block.

If I copy kirby/config/blocks/list/list.php to site/snippets/blocks/list.php and replace

<?= $block->text(); ?>

with

<?= $block->text()->permalinksToUrls(); ?>

it again results in the cryptic page urls. And moreover it results in „wrong“ links for mailto: or tel:, e.g.

domain.de/"mailto:email@address.com"

and

domain.de/"tel:+4930123456789"

Is there any other trick for the list block?