Page.find fails only on custom route


Hello there,

i ve setup a route like /keyword -> /blog/keyword in the site.yaml. If the the page is invoked by this route the following find doesnt work as expected:

  <div class="links">
  {% set _p_links = page.find('/_footer/links') %}

The weired thing is that the _p_links object isn’t empty. It points to the /blog/keyword/

Does a custom route break such find instructions in general?

I use my own theme. All is up to date.

Thank u in advance.


@npetri Is ‘/_footer/links’ located at the top level of folder ‘/user/pages’? Like ‘/user/pages/_footer/links’.

page.find('/...) Starts searching for a page from the root of the pages folder.

When I use your script in the ‘blog-skeleton’ in ‘blog.html.twig’ and use “page.find(’/blog/hero-classes’)”, it correctly prints the content of page ‘hero-classes’, which is at ‘user/pages/’

Uhh… no, “page.find(’./hero-classes’)” does not find it…

If the file cannot be found, it seems to return a reference to the current page. Not sure if that is logical…


Thank u for checking on that!

Yea the /_footer/links’ is within the /usr/page folder. Otherwise it could never be found, but it works when in ‘normal’ cases. But it behave different if its used in a context of a custom a route. And like u also discovered, it returns an unexpected page, the current one. In my case, the page content of a blog item was pasted in the footer twice, bcs i have two of this find calls there.

My solution atm is not to use a custom route.


Wat is your folder structure?

I do use a custom route and ‘page.find()’ works properly when using the right folder path.





The is a modular page, the home route is set to this page.


TL;DR: Again, could not reproduce the issue…

Did the following:

  • Fresh blog-skeleton + admin + devtools
  • Created following folder structure:
       01.home/        // Copied modular with subfolders from skeleton-one-page        // Renamed original folder from skeleton-blog
          keywords/    // Added

  • Inserted the following code into ‘blog.html.twig’ and ‘partials/blog-item.html.twig’:
    <div class="links">
      {% set _p_links = page.find('/_footer/links') %}
      <p>Template = "{{page.template}}"<br>Url = {{ _p_links.url}}</p>
  • Inserted into site.yaml’
      /keyword: /blog/keyword

Tested the following urls in the browser:

Note: All tested urls printed correct content of ‘_footer/links/’

Am I missing some info?


Wow, thank u for ur effort. The code block that doesnt work is inside the footer partial that is used by the base.html.twig. The modular page that is called via / which points to /pages/01.home is extending this base.html.twig.

I can share my whole grav installation as a zip if u want to reproduce it.

Thank you very much.


Changed footer block of ‘base.html.twig’ to:

{% block footer %}
    <div class="links">
       {% set _p_links = page.find('/_footer/links') %}
       <p>Template = "{{page.template}}"<br>page.find('/_footer/links') = {{ _p_links.url}}</p>
{% endblock %}

In the footer, the same results are displayed as in above tests.


Preliminary result: I checked some options that maybe related to routes. I had disabled the default language in route. So i enabled this option and now the page.find() call works as expected. I will do some further test…


Hello again,

its all related to the option routeable: false. However, in this case page.find() deliver the current page as a fallback. I don’t know if this is suppost to be.

This option was set in the related files by accident. Probably, it was already set in the markdown file that i used as template for this files. In the admin panel, non routable pages have a red plus instead of grey or blue, but i didn’t get it.



Does this mean your problem is solved?


Yes, i just tagged it as solved.