# Accessing indifferently \`foo/bar.md\` and \`foo/bar/index.md\`

**URL:** <https://zola.discourse.group/t/accessing-indifferently-foo-bar-md-and-foo-bar-index-md/2184>\
**Category:** Support\
**Created:** [June 28, 2024, 8:56am UTC](https://zola.discourse.group/t/accessing-indifferently-foo-bar-md-and-foo-bar-index-md/2184 "2024-06-28T08:56:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![loutr](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/loutr/32/1246_2.png) [@loutr](https://zola.discourse.group/u/loutr)\
**Post date:** [June 28, 2024, 8:56am UTC](https://zola.discourse.group/t/accessing-indifferently-foo-bar-md-and-foo-bar-index-md/2184/1 "2024-06-28T08:56:44Z")

</div>

Hi everyone,

I would like to achieve something like this:

```auto
{% set a = get_page(path="foo/" ~ filename ~ ".md", required=false) %}
{% if not a %}
  {% set a = get_page(path="foo/" ~ filename ~ "/index.md") %}
{% endif %}

```

i.e., loading a page of a known section but with a filename that can either refer to a file or a folder (because of “colocation”). However:

- the `required` argument that exists for `load_data` does not exist for `get_page`;
- is it possible to factor this into some sort of macro? As it will be used quite a few times, and it would be much more handy to write something like `a = get_page_from(section="foo", filename=filename)`.

Thanks a lot
