Git Product home page Git Product logo

Comments (3)

liwenyip avatar liwenyip commented on June 24, 2024

HEG doesn't normally need you to use a shortcode in a template file.

What are you trying to do?

In general, if you want to call a shortcode from a template, copy and paste the contents of the shortcode into your template.

from hugo-easy-gallery.

JorisEekhout avatar JorisEekhout commented on June 24, 2024

I had the same question. I want to call the gallery shortcode from a single.html layout file. The directory argument should come from the front matter. Something like this:
{{< gallery dir="/images/{{ .Params.dir }}" />}}

But like beatrice said, shortcodes do not work in template files. Any ideas?

from hugo-easy-gallery.

liwenyip avatar liwenyip commented on June 24, 2024

You'll need to copy gallery.html into your template file, or into partial template which you call from your main template.

You'll have to hard-code all the variables normally passed to the shortcode (i.e. every instance of .Get).

e.g. Change

<div class="gallery caption-position-{{ with .Get "caption-position" | default "bottom" }}{{.}}{{end}} caption-effect-{{ with .Get "caption-effect" | default "slide" }}{{.}}{{end}} hover-effect-{{ with .Get "hover-effect" | default "zoom" }}{{.}}{{end}} {{ if ne (.Get "hover-transition") "none" }}hover-transition{{end}}" itemscope itemtype="http://schema.org/ImageGallery">

to

<div class="gallery caption-position-bottom caption-effect-slide hover-effect-zoom hover-transition" itemscope itemtype="http://schema.org/ImageGallery">

from hugo-easy-gallery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.