Perhaps instead of .Site.RegularPages you can try .Pages instead?
.Site.RegularPages
a shortcut to the regular page collection. .Site.RegularPages is equivalent to where .Site.Pages “Kind” “page”.
Specifically:
The .Pages Variable
.Pages is an alias to .Data.Pages. It is conventional to use the aliased form .Pages.
.Pages compared to .Site.Pages
A regular page is a “post” page or a “content” page.
A leaf bundle is a regular page.
A list page can list regular pages and other list pages. Some examples are: homepage, section pages, taxonomy term (/tags/) and taxonomy (/tags/foo/) pages.
A branch bundle is a list page.
Well, what you’re essentially doing is checking the page’s front matter for categories = [“something”, “something else”] which may not be the best to depend on front matter. Instead, try to filter out the pages using the project directory/file structure, such as using .Pages not from section Blog.
Ok, I got started with using categories in front matter from a theme I decided to use; it was set up that way. Maybe that’s not a good way, i.e. my newer question? Custom template for one category?