How to request just a parent via KQL (no children) and get a non-200 if it doesn't exist?

Is there any way with KQL to request just a parent and have it return a non-200 code if it’s not found?

I’m currently seeing that if the parent parent-template.txt file is not present but children directories are it returns a 200 (which for my purposes makes it feel broken, since what I’m wanting is the parent/root).

Example:

"query": "page('blog')"

This returns a 200 regardless of whether /blog/parent-template.txt exists if there are nested (child) directories (e.g. blog/post-1/)

But a page exists for Kirby if the folder exists, no matter if you have a text file in it or not.

Right, but if there’s no template page for a parent index, it seems strange to me that Kirby would still consider the page to exist (since there’s no text file on disk for it).

I ended up re-working the need for this so that it’s not an issue any more for my particular usecase, but I do still find it an awkward/unexpected approach to the filesystem API (if there’s no file, there’s no file, regardless of a directory’s presence, at least logically in my mind).

It wouldn’t make sense if it wasn’t a page, considering that you even added children to it. Children can only exist if they have a parent.

In any case, for Kirby it doesn’t matter, if there is no text file, Kirby will use the default template to render the page and the folder name will serve as title.

May I please remind you not to post in two places (forum and Discord) without referencing your duplicates? It’s a waste of time for people trying to help if they always have to check if the question has already been answered somewhere. Thank you.

So sorry! Yes, will do this in the future. Will likely just post here in the future since I find the UI here better for searching and such.

1 Like