# Get page metadata from base.html

**URL:** https://zola.discourse.group/t/get-page-metadata-from-base-html/2316
**Category:** Support
**Created:** [October 8, 2024, 11:50am UTC](https://zola.discourse.group/t/get-page-metadata-from-base-html/2316 "2024-10-08T11:50:30Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![alirezaalavi](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@alirezaalavi](https://zola.discourse.group/u/alirezaalavi)
#### Post date: [October 8, 2024, 11:50am UTC](https://zola.discourse.group/t/get-page-metadata-from-base-html/2316/1 "2024-10-08T11:50:30Z")

</div>

Hi guys.

- I have a nav.html which is included in my base.html
- I want nav.html to get `extra.banner` from the current page

problem:  
nav.html and base.html don’t have access to `page`

the end goal:  
I want the layout and style of my `nav.html` to change based on if the current page has a banner set or not.

---

<div class="post-metadata">

### Author: ![charlie137](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/charlie137/32/1140_2.png) [@charlie137](https://zola.discourse.group/u/charlie137)
#### Post date: [October 12, 2024, 5:14pm UTC](https://zola.discourse.group/t/get-page-metadata-from-base-html/2316/2 "2024-10-12T17:14:47Z")

</div>

`if page` then `if page.extra.banner`?

---

<div class="post-metadata">

### Author: ![alirezaalavi](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@alirezaalavi](https://zola.discourse.group/u/alirezaalavi)
#### Post date: [October 13, 2024, 1:36pm UTC](https://zola.discourse.group/t/get-page-metadata-from-base-html/2316/3 "2024-10-13T13:36:58Z")

</div>

this doesn’t fix the actual problem. Maybe I explained it badly.  
I want to know the value of `banner` from the current page I’m on, from within `nav.html` because I want to change the style of my navigation bar for the pages that have a banner.

The problem is I can’t even check if a page has a `banner` or not. because `nav.html` doesn’t have access to the `page` variable.

---

<div class="post-metadata">

### Author: ![alirezaalavi](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@alirezaalavi](https://zola.discourse.group/u/alirezaalavi)
#### Post date: [October 13, 2024, 1:58pm UTC](https://zola.discourse.group/t/get-page-metadata-from-base-html/2316/4 "2024-10-13T13:58:17Z")

</div>

Oh God nevermind!  
This actually fixes the issue. I understand now the error was because the home page. doesn’t have `page` variable. so I have to first check if the `page` variable even exists.

the current working code in `nav.html`

```auto
{% if page.extra.banner or current_path == "/" %}
    {% set header_class = "header--banner" %}
{% else %}
    {% set header_class = "header" %}
{% endif %}

<header class={{header_class}}>

```

Thank you so much for the tip. my brain was fried.
