<p>It looks like you're missing a closing <code>{% endcache %}</code> tag towards the end of your template.</p>

<p>(See <a href="https://docs.craftcms.com/v3/dev/tags/cache.html" rel="nofollow noreferrer">https://docs.craftcms.com/v3/dev/tags/cache.html</a>)</p>

<p>You might also be missing a closing <code>{% endminify %}</code> tag too, but I'm not sure if you've posted the whole of your template or not.</p>

CC BY-SA 4.0
2020-04-05T10:42:42.910Z
2020-04-05T10:42:42.910Z
James Greig
<p>it looks like you started with a given set of templates, maybe from some kind of example craft template site. 
while this is always great for learning the details, it can make things difficult being new to craft/twig because this error belongs to the minify-plugin which "only" serves optimization. you should start the other way around and start with some sort of a blank canvas so to speak and add things… like an include, a loop, image loop, randomization, etc.</p>

<p>that way it's easier to keep focus and you won't get distracted by things or functions or in this case a plugin, which isn't necessary for the basics.</p>

CC BY-SA 4.0
2020-04-06T18:59:13.957Z
2020-04-06T18:59:13.957Z
Matthias
<p>I am getting the following Twig error and I cannot figure out what is wrong. I'm new to Twig.</p>

<pre><code>Twig Syntax Error – Twig\Error\SyntaxError

Unexpected "minify" tag (expecting closing tag for the "cache" tag defined near line 5).

in /var/www/craft/templates/index.twig at line 5

{% extends "_layouts/_layout.twig" %}

{% import "_partials/_macros.twig" as macros %}

{% block content %}

{% cache using key "home-page" %}{%- minify -%}

{% set banner = entry.homeBanner.one() %}

&lt;div class="home-banner"&gt;

  &lt;img class="home-banner__image js-object-fit"

 src="{{banner.image[0].getUrl('homePageBanner')}}"/&gt;

  &lt;div class="home-banner__container container"&gt;

    &lt;div class="row justify-content-center"&gt;

      &lt;div class="col-10 col-md-8"&gt;

        &lt;h1 class="h1 home-banner__heading"&gt;{{banner.heading}}&lt;/h1&gt;

      &lt;/div&gt;

      {% set bannerBtn = banner.button.one() %}
``
</code></pre>

<templating><craft3>
Need help with a Twig template error
# Need help with a Twig template error

(Asked by: username_0 on 2020-04-05)

I am getting the following Twig error and I cannot figure out what is wrong. I'm new to Twig.
Twig Syntax Error – Twig\Error\SyntaxError

Unexpected "minify" tag (expecting closing tag for the "cache" tag defined near line 5).

in /var/www/craft/templates/index.twig at line 5

{% extends "_layouts/_layout.twig" %}

{% import "_partials/_macros.twig" as macros %}

{% block content %}

{% cache using key "home-page" %}{%- minify -%}

{% set banner = entry.homeBanner.one() %}



  

  

    

      

        {{banner.heading}}

      

      {% set bannerBtn = banner.button.one() %}
``

**Tags:** templating, craft3


---

## 2 answers

### Answer by username_1 on 2020-04-05. Score: 2

It looks like you're missing a closing `{% endcache %}` tag towards the end of your template.

(See <https://docs.craftcms.com/v3/dev/tags/cache.html>)

You might also be missing a closing `{% endminify %}` tag too, but I'm not sure if you've posted the whole of your template or not.


---

### Answer by username_2 on 2020-04-06. Score: 1

it looks like you started with a given set of templates, maybe from some kind of example craft template site.
while this is always great for learning the details, it can make things difficult being new to craft/twig because this error belongs to the minify-plugin which "only" serves optimization. you should start the other way around and start with some sort of a blank canvas so to speak and add things… like an include, a loop, image loop, randomization, etc.

that way it's easier to keep focus and you won't get distracted by things or functions or in this case a plugin, which isn't necessary for the basics.


---

