Redirect index to subpage

Hello. I’ve just started using Kirby with the Kiii theme. When users visit the base of my site (/), I want to send them straight to my blog (/thoughts).

Note that I don’t want to change the base URL for the whole site, as other pages like About should still live at /about, not /thoughts/about.

What’s the best way to do this?

Hello krotondo,

I think there is two ways to do this and I would recommand the first one :

  1. Simply rename the “thoughts” folder in the “content” folder to “home”. Kirby will detect that it is your home page and will link it to your main url.

  2. In site/config/config.php (create the folder and the file if it doesn’t exist), write :

<?php

return [
  'home' => 'thoughts',
];

Thanks Adrieng.

Neither of these does quite what I want, because they both force the page name in the navigation to be “Home”, when I want it to stay “Thoughts”. Do you have any other ideas?

What @Adrieng suggested in suggestion 2 would be the way to go. The page should then show up correctly in the navigation. Having said that, I’m not sure what your theme does internally… Could you try to find the navigation part in the code and post it here.

I ended up being able to solve it by adding a route to my site/config/config.php:

  'routes' => [
    [
      'pattern' => '',
      'action'  => function () {
        return page('thoughts');
      }
    ]
  ],

Thanks for the help!

1 Like