Setting URL-Key automatically

You can achieve this by using a panel hook in site/config/config.php

kirby()->hook('', function($page) {
  try {
      'URL-Key' => str::slug($page->title()),
  } catch(Exception $e) {
    echo $e->getMessage();

There are some Problems

  • It only works with languages which are not the default languages (as discussed here).
  • The URL-Key gets updated each time the title is changed. Why? You can’t use because this hook is fired when you change the language in the panel to create the page in the new language and at this moment the fields are prepopulated with the values from the default language. And this leads to an url key in the wrong (default) language …

But it was fun to check this out :smile: