1

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() %}

<div class="home-banner">

  <img class="home-banner__image js-object-fit"

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

  <div class="home-banner__container container">

    <div class="row justify-content-center">

      <div class="col-10 col-md-8">

        <h1 class="h1 home-banner__heading">{{banner.heading}}</h1>

      </div>

      {% set bannerBtn = banner.button.one() %}
``
| improve this question | | | | |
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.

| improve this answer | | | | |
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.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.