I am confused about the site structure...help!

In the past I have used Processwire which shows the page tree in the admin with one top level page:

Now I am a bit confused with Kirby because it appears you can have multiple top level pages.

So should I have a ‘Projects’ folder at the top level as a sibling to Home like the starterkit? The problem with this is I wasn’t planning on having a ‘Projects’ page on the front end. So perhaps I should have each project as a child of Home?

Any thoughts?

Thanks

The “Home” you are used to from processwire is the $site variable (in your Panel you can reach it over the Hamburger Menu in the top left corner -> Site Options) - I would suggest using a Projects Folder as a sibling to your Home folder in Kirby which contains your Projects (Project 1 , Project2, etc.). That way you get a subpage for your projects (yourdomain.com/projects) as well as for all single projects (yourdomain.com/projects/project-1).

1 Like

Oh that is great, I was scratching my head but now I understand! I was wondering where the panel for site.yml was!

I think it is slightly different because Home in processwire is actually a page…hmmmm

I am not familiar with processwire, sorry. I guess it is a mixture of both (the $site variable and the home-folder/page).

Yes, the structure in Kirby is a bit different, home is in fact the start page with no slug in the URL, it only get’s the home slug when children are added as subpages and you call these URLS.

$site is not a page, it only contains content that should be available via the site object. The site object can also have images, if you want a more central place for them.

1 Like

Alternatively I could do away with the ‘Projects’ folder altogether and I can choose to put each project as either a sibling or child of home it won’t really matter will it?

I am trying to build a knowledge base. On the homepage will be a list of Projects which when clicked will take you to the page for that Project. There wasn’t going to be another page called Projects with a list of all projects because the list is on the homepage. Does that make sense?

Yes, in that case I’d make the projects children of /home.

Edit: if you like, you can then use a route to get rid of the home slug for these subpages: https://getkirby.com/docs/developer-guide/advanced/routing

1 Like

@macgyver:

I suggest to install Kirby Starterkit. There you can see, how to show projects on the homepage, where the parent of every project is on the same level than home.

Good luck!

You can always have all your content pages at the root, and the home page alongside it:

content/
    home/
    1-some-page/
    2-some-other-page/
    3-yet-another-page/
    site.txt

You can think of $site as the PHP equivalent of the content folder. Its text content, if any, comes from the content/site.txt file, and there is no URL that shows this root “page”: it’s mostly used to store metadata about your site, which you can use in your templates, for instance:

<head>
  <title><?= $page->title() . ' - ' . $site->title() ?></title>
</head>

Now if you want to output a list of first-level pages excluding the home page, you could get this list like this:

<?php
$pages = $site->children()->visible();
foreach($pages as $p) {
  echo $p->title() . '<br>';
}
?>

Here we’re using Kirby’s concept of “visible” pages, which are pages ordered with an index number. If for some reason you want to skip the index numbers, you will need to filter out the home page:

<?php
$pages = $site->children()->not('home');
foreach($pages as $p) {
  echo $p->title() . '<br>';
}
?>
2 Likes

@fvsch Thank you for the great explanation