Writing a new thread because I’m somewhat stuck here. This topic is more complicated, it seems, and the previous discussion was for Kirby v3, so I think that having a new thread for the current and the next version makes sense - it’ll take me a few more months to have my Kirby installation ready, and I’m positive that v6 will be released by then. ![]()
What I try to achieve is a WordPress-like /blog/yyyy/mm/slug structure. Example /content/ structure from my testing environment:
% find content
content
content/home
content/home/home.txt
content/blog
content/blog/2026
content/blog/2026/07
content/blog/2026/07/testpost
content/blog/2026/07/testpost/article.txt
content/site.txt
content/error
content/error/error.txt
I try to create the folder structure automatically, via site/models/article.php:
<?php
class ArticlePage extends Page {
public static function create(array $props): Kirby\Cms\Page
{
$date = $props['content']['date'] ?? date('Y-m-d');
$year = date('Y', strtotime($date));
$month = date('m', strtotime($date));
$blog = page('blog');
$yearPage = $blog->find($year);
if ($yearPage === null) {
$yearPage = Page::create([
'parent' => $blog,
'slug' => $year,
'template' => 'archive.year',
'content' => ['title' => $year],
'draft' => false,
]);
}
$monthPage = $yearPage->find($month);
if ($monthPage === null) {
$monthPage = Page::create([
'parent' => $yearPage,
'slug' => $month,
'template' => 'archive.month',
'content' => ['title' => $month],
'draft' => false,
]);
}
$props['parent'] = $monthPage;
return parent::create($props);
}
}
?>
Now I wonder what I did wrong, because that does not create subfolders - the resulting posts are in yyyymmdd_slug instead. And I can’t seem to fetch them. I expanded site/templates/default.php to try and read them, but it doesn’t work:
<!doctype html>
<html>
<head>
<?php snippet('scss') ?>
<?php snippet('webmention-endpoint'); ?>
</head>
<body>
<h1><?= $page->title()->html() ?></h1>
<?php foreach($page->index()->filterBy('article')->listed()->flip() as $article): ?>
<article>
<h1><?= $article->title()->html() ?></h1>
<p><?= $article->text()->excerpt(300) ?></p>
</article>
<?php endforeach ?>
</body>
</html>
All I get is <h1>Home</h1>. Maybe I misunderstand how Kirby works (21 years of WordPress, 27 years of occasional PHP, still trying to grok Kirby’s basics), so I’ll probably need a hint here. ![]()
