Menu icon Foundation
Override default custom data

I have a simple template with header, footer, etc partials. In my header there is a banner with a link defined by custom data in src/data. I would like to be able to override this on a page by page basis, is there a way to do this? Below is what I have tried, but doesn't work. The banner-url.yml seems to take precedence over the inline variable declaration in the-page.html.

The Jekyll Front Matter defaults is a similar behavior to what I'm looking for.

src/partials/header.html:

<a href="{{ banner-url }}"><!-- banner image --></a>

src/data/banner-url.yml:

https://foundation.zurb.com/

src/pages/the-page.html:

---
banner-url: https://duckduckgo.com/
---

{{> header}}

paninijekyll

I have a simple template with header, footer, etc partials. In my header there is a banner with a link defined by custom data in src/data. I would like to be able to override this on a page by page basis, is there a way to do this? Below is what I have tried, but doesn't work. The banner-url.yml seems to take precedence over the inline variable declaration in the-page.html.

The Jekyll Front Matter defaults is a similar behavior to what I'm looking for.

src/partials/header.html:

<a href="{{ banner-url }}"><!-- banner image --></a>

src/data/banner-url.yml:

https://foundation.zurb.com/

src/pages/the-page.html:

---
banner-url: https://duckduckgo.com/
---

{{> header}}
Rafi Benkual about 2 years ago

So you are trying to override a data from a data file by assigning the same variable a value at the page level?

How would you use this feature? Maybe we can suggest another way.

David Giove about 2 years ago

So for example if I have 20 pages that all declare:

---
banner-url: https://foundation.zurb.com/
---

But I only have one page that declares:

---
banner-url: https://duckduckgo.com/
---

It would be nice to have a default attribute for banner-url that I could override on the single page that needs it instead of declaring it on each page. Does that make sense?