How to filter children pages without dependency on url slug?

I am using this method to show projects on the page Projects:

<?php foreach ($site->find('projects')->children()->listed()->limit(4) as $post): ?>

The problem is, if I change url from “projects” to another (in multilingual site for example), filter is not working. Tried to filter by template $site->find('template','projects'), but it’s not working.

Can you help with this? Best I think would be to filter by template.

You can use filter by template:

Should work if you use the page helper

page('projects')->children()...

Thank you, that helps!

Also now need to change this in blueprint: parent: site.find("projects"), tryed parent: index.find.page("projects") and it’s working, just not sure if it’s best way.

And how to print url to “Projects” page? Was using this before: <?= $site->find('projects')->url() ?>

What about using the helper in the blueprint as well?

<?= ($page = page('projects') ? $page->url() : '' ?>

The syntax you used to use it not save to use, anyway.

If you want the code to still work if the folder is renamed, you could get the page by template

$projectsPage = $pages->findBy('template', 'projects')

If the user can change the template, however, that will still not work and you would have to introduce some sort of permanent ID (e.g. using the AutoID plugin). But if I got you right, you are only concerned about the language slug, not the slug of the default language being changed?