Home slug not included in subpages url

#1

Not sure if there’s something going on with my setup or what but is it normal that the home is no longer included in the url of its subpages?

I have a blog where the posts are direct children of the homepage.
In K2 I was using a route to get rid of the /home/.

:thinking:

Ok the slug was some weird leftover from my K2 installation but for some reason the url() method is still printing the url without the /home/ part.

0 Likes

#2

That’s probably the reason why pointing the home page to another page results in a 404 error when trying to load a subpage: https://github.com/getkirby/kirby/issues/1371

0 Likes

#3

Ah interesting. Still, that doesn’t explain why $page->url() called on a subpage is returning the url without the home part. That’s happening even if I don’t change the name of the homepage in the settings

To expand:

return [
    # Kirby Settings
    'debug' => true,
    'cache' => false
];

Even with just this in my config, if in my snippet I loop through the subpages of the homepage and print

<?= $p->url() ?> (where $p is the current post)

What I get is

.com/subpage-slug

0 Likes

#4

Yes, exactly, and I assume that’s the router doing this. Does this at least work for the homepage called home?

0 Likes

#5

Nope. As I said, this is happening even if I use the home called home :face_with_raised_eyebrow:

It’s funny because on my K2 I was using a page model to overwrite the url() method and remove the home part. Now it’s happening no matter what.

And I only noticed that there was a problem because the preview of a draft was returning the error page

0 Likes

#6

Yes, I got that (and some more chars)

0 Likes

#7

If I dump the $page variable this is what I get

[uid] => post-title
[uri] => home/post-title
[url] => http://site.com/post-title
0 Likes

#8

In my test, the subpage of the home page called home (with that truncated URL) also returns an error page (the same as when the home page is called something else). Can you confirm this?

0 Likes

#9

Can confirm that yes.

0 Likes

#10

I updated the issue, for me that is the same thing: https://github.com/getkirby/kirby/issues/1371

Because of the missing slug, subpages of home, no matter if that page is called home or something else, resulting in 404.

1 Like

#11

Until this issue is fixed, you can use a route to temporarily work around this.

0 Likes

#12

Yes the route was already in place in my case so that’s not a huge issue. Unfortunately the draft preview is broken and I think it’s because of the same issue

0 Likes