Eleventy Nunjucks extend template block renders empty space

67 views Asked by At

Hello :) I've set up a basic @11ty project. My templates are .html and my template engines are njk.

While {% include %} for partials and {% extend %} for layouts works as expected, I cannot get {% block %} to work.

Here's a stripped-down repo: https://github.com/wcDogg/eleventy-test-njk-blocks.git.

This is in _includes/layouts/base.html:

<main>
  <h1>{{title}}</h1>
  {% block test %}{% endblock %}
  {{ content | safe }}
</main>

This is in _includes/layous/page-blog.html:

{% extends "base.html" %}
{% block test %}
<a href="#">Test Link</a>
{% endblock %}

When I use the layout: "layouts/page-blog.html", it extends as expected, but the block renders as empty space - as seen on ./public/blog/index.html.

This is foundational to how I'd like to use @11ty - any help is much appreciated.

1

There are 1 answers

0
wcDogg On BEST ANSWER

Code error on my end. Fixed in repo if interested in the example :)