Routing / Virtual pages

Hi guys,

I have a setup that needs routing/virtual pages (?)


  • set of pages located in: /content/projects/[slug]
  • the pages should be available in: /work/[slug]
  • multilingual (2 languages so far)
  • the pages contain files
  • the pages need a navigation. they need to know their siblings

I have tried with routing in the config.php. No bingo so far.

'routes' => [
    'pattern' => array(
      'work/(:any)', // EN
      'arbeiten/(:any)' // DE
    'language' => '*',
    'action'  => function($language, $path) {
      $originPage = kirby()->page('content/projects/'. $path);

      if (!$originPage || $originPage->slug() !== $path) {
        return false;

      $data = [
        'slug' => $originPage->slug('en'),
        'parent' => page('work'),
        'language' => $language,
        'template' => 'page.project',
        'files' => $originPage->files()->toArray()
        'translations' => [
          'en' => [
            'code' => 'en',
            'content' => $originPage->content('en')->toArray()
          'de' => [
            'code' => 'de',
            'content' => $originPage->content('de')->toArray()

      return Page::factory($data);

There is a problem with srcsets/thumb-creation and i am sure the pages cannot know their siblings (navigation not yet started).

What am i missing?

You need to pass the path to the page without the content bit. Unless you actually have a folder called content inside the content folder.

But I don’t quite understand the purpose? Why don’t you rename projects to work instead of providing the same content under multiple urls?

Or do the pages work correctly and you only have a problem with the images?

Yes, from the kirby-root there is actually this structure /content/content/projects.
I separated actual “data” from “pages” (as “presentation”-pages) and I could not come up with a better name than “content” :stuck_out_tongue:

The pages are working except their thumbnails (Error: File not found).
When I remove the “files”-property, the pages show up (with no files).

Also, how will the pages know their siblings (for navigation) ?

For such cases, it would be better to define the pages as children of the parent page in a page model, as in the Virtual pages examples instead of using a route: Virtual pages | Kirby CMS.

The files also would have to defined in the model for the actual children pages.