First page of collection as homepage

Hi,

is it possible to redirect the first page of a collection (e.g. first project of a portfolio) as homepage? like here in the config.php:

return [
    'home' => 'projects'
];

Not tested this but i think you should be able to do either of these (assuming you have a projects collection setup already):

return [
    'home' => kirby()->collection('projects')->first()->id()
];

or

return [
    'home' => site()->find('projects')->children()->listed()->first()->id()
];

looks promising, but both throw an error so far. :slightly_frowning_face:

What was the error?

first one:
Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 262144 bytes) in /…/kirby/config/helpers.php on line 276

second one:
Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) in /…/kirby/src/Cms/Core.php on line 334

Hmm yes its running out of ram and needs another 20+ gigbytes, so its obviously going round in circles. Not really sure where to go from here to be honest.

You cannot call kirby() or site() in the config, unless you do so within the ready option. You can set your home option there:

1 Like