aaranxu / adidoks

AdiDoks is a mordern documentation theme, which is a port of the Hugo theme Doks for Zola.
https://adidoks.org
MIT License
227 stars 81 forks source link

How to add custom variables in theme? #68

Closed neeteshp closed 7 months ago

neeteshp commented 7 months ago

When I try to add custom variables in templates/index.html, it throws error.

content/_index.md [extra] lead = 'Navigating' url = "getting-started/" url_button = "Get started" test = "Test" \ templates/index.html

<div class="col-lg-9 col-xl-8 text-center">
  <h3>
    {{ section.extra.test | safe }}
    <small class="text-muted">With faded secondary text</small>
  </h3>
  <p class="lead">{{ section.extra.lead | default(value="Please start setting config.toml and adding your content.") | safe }}</p>
  <a class="btn btn-primary btn-lg px-4 mb-2" href="{{ get_url(path=section.extra.url | default(value="/"), trailing_slash=true) | safe }}" role="button">{{ section.extra.url_button }}</a>
</div>

\ Error - Error: Failed to build the site Error: Failed to render section '/home**/content/_index.fi.md' Error: Reason: Failed to render 'index.html' Error: Reason: Variable section.extra.test not found in context while rendering 'index.html'

xNS5 commented 7 months ago

This looks like zola is looking for content/_index.fi.md when you added to content/_index.md. If that key isn't present on _index.fi.md, it makes sense that it won't render properly.

neeteshp commented 7 months ago

@xNS5 It worked, thanks.