I’m trying to make tags have their own URL. Right now it’s…
/tag:mytag
And I’m looking to change it to…
/tag/mytag
Currently I have this…
[
'pattern' => '(:any)',
'action' => function($uid) {
$page = page($uid);
if(!$page) $page = page('home/' . $uid);
if(!$page) $page = site()->errorPage();
return site()->visit($page);
}
],
[
'pattern' => 'home/(:any)',
'action' => function($uid) {
go($uid);
}
],
My root URL is /
for all my pages and posts in my blog. And all is working great.
I’ve done a bunch of research on the forum and in the docs and I’m a little confused in getting the tag URL working.
I have tried adding this below…
[
'pattern' => '/',
'action' => function() {
$tag = kirby()->request()->params()->get('tag');
if ($tag) {
return go('/tag/' . Str::slug($tag));
} else {
return page('home');
}
}
],
And although this does change the URL to /tag/mytag
, it actually renders the error page rather than the tag page I need.
Can anyone point me in the right direction as to what I’m doing wrong?
I’m going a little stir crazy this Christmas evening
Thanks!