Partial -> html Document -> Shortcodes

Hello!
I have another question… In embedded a partial in my main layout like this:

{{ partial "modal.html" (.Site.GetPage "videos") }}

In the “modal” partial, i use {{ .Content }}. The content from the videos.html is getting implemented there. However I try to use shortcodes within the videos.html content file such as {{ range index .Site.Data.videos }}, but it is getting just displayed instead of the output of that shortcode. I guess it is because this file is implemented as content of a partial. Is there an operator to make the content been outputtet with shortcodes, such as {{ .Content | shortcoded }}?

Can you confirm you have the following three parts:

  • Content templates for your video pages within /layouts/videos/ directory.
  • A shortcode for video within your /layouts/shortcodes/
  • The actual shortcode in use on a content page, say in content/videos

Hello!

No, my content page is within the content directory and is actually found by the .Site.GetPage “videos”.
Also I have a partial called “modal” in the partial subfolder. Actually I’m sorry for using the right word… It’s not a short code, but I did the liquid (or however it’s called) field {{ .Content }} in my partial and all I want, is that other “liquid” fields such as the range function can be executed within this content file instead of getting displayed…

Sorry for the unclear explanation…

Please post a link to the public repository for your site. See:
https://discourse.gohugo.io/t/requesting-help/9132

Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.

If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.

Hello!

The page is not yet live on a server. But I’ll try to explain better (…and removed some unnecessary content).

/layouts/index.html:

<html>
  {{ partial "head.html" . }}
  <body>

    <div class="logo">
      <img src="images/logo.png" srcset="images/logo.png" />
    </div>

    {{ partial "sidebar.html" . }}
    {{ partial "content.html" . }}

    {{ partial "modal.html" (.Site.GetPage "info") }}
    {{ partial "modal.html" (.Site.GetPage "join") }}
    {{ partial "modal.html" (.Site.GetPage "videos") }}

  </body>
</html>

/layouts/partials/modal.html:

<div id="modal" class="modal " tabindex="-1" role="dialog">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <a class="btn modal-close"></a>
      </div>
      <div class="modal-body">
        <div class="contentwrapper centered">
          {{ .Content }}
...

/content/videos:

+++
Title = "videos"
+++
<div class="contentbox infobox">
  <div class="videos-container">
    <div class="videos-header">
      <div class="title">****</div>
      <div class="separator"></div>

—> THIS RANGE FUNCTION WILL JUST GET ECHOED INSTEAD OF RANGING TROUGH THE DATA JSON:

  {{ range index .Site.Data.videos }}
{{***}}
{{end}}
</div>
  </div>
</div>

Ok… well sorry for not reading correctly, this might not help you. I thought that you get my point in what is not working. It looks more like a well known behaviour than a bug to me - that’s why I thought you could just push me to the right direction. :wink: I’ll try to create a dummy repo.

So @jmooring, here is the public repo showing my problem:

You cannot place template code inside of a content file, regardless of whether that content file is markdown, HTML, or something else.

But things like

{{% include “join_html.html” %}}

work in a content file, if I’ve added a shortcode for include

That’s a shortcode, not template code.

OK, so I guess no way, even by a workaround. You can close this task then. Thx!

Put your code in a shortcode, then call the shortcode from the content file.