aaranxu / adidoks

AdiDoks is a mordern documentation theme, which is a port of the Hugo theme Doks for Zola.

Home Page:https://adidoks.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to add custom variables in theme?

neeteshp opened this issue · comments

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'

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.

@xNS5 It worked, thanks.