Iframe content is empty

Hi there,

I am trying to display an iframe on my hugo site.
But no matter what I do, the head and body elements are empty.
They are not getting generated at build time.

I have tried several approaches, that I have found in this very place :
https://discourse.gohugo.io/search?q=iframe

in particular : https://discourse.gohugo.io/t/generate-iframe-source-in-template/15654

  1. I have tried with a shortcode with my iframe inside.
  2. I have tries to use a partial that’s get called from a shortcode.

in .md file :

{{< part1/sc_iframe >}}

in part1/sc_iframe :

{{ partial “iframe.html” . }}

in shortcode iframe.html

<iframe style="width:120px;height:240px;" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src="https://www.strava.com/activities/2330518629/embed/bc0c587811e9409ef8084daa68114e54acb47286">
</iframe>

The iframe is still emplty.

What I am doing wrong ?

Thanks.

I’m unable to reproduce the problem. Check your directory structure:

layouts/
├── _default
│   ├── baseof.html
│   ├── list.html
│   └── single.html
├── partials
│   └── iframe.html
└── shortcodes
    └── part1
        └── sc_iframe.html

layouts/shortcodes/part1/sc_iframe.html

{{ partial "iframe.html" . }}

layouts/partials/iframe.html

<iframe style="width:120px;height:240px;" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src="https://www.strava.com/activities/2330518629/embed/bc0c587811e9409ef8084daa68114e54acb47286">
</iframe>

I have the same structure as you do.
And I forgot to mention that I have :

  • [markup.goldmark.renderer]
    unsafe= true

  • Hugo Version : 0.75.1-1

Still unable to reproduce the problem.

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.

1 Like

you are right :

here is a fresh repo with a fresh hugo generated site with the uncooperative iframe :

You’ll find the iframe inside :

http://localhost:1313/post/test_iframe/

Hold on !

I was working on Firefox and out of an hunches I tried on Brave and it works !

Firefox version : 81.0 (64-bit)
Brave : Version 1.12.105 Chromium: 84.0.4147.105 (Official Build) unknown (64-bit)

So my iframes are not working on FF (I have all security modules deactivated on FF / Localhost)

Nope, I was wrong again, it was Ghostery that wasn’t properly deactivated for localhost:1313

So thanks a lot jmooring, our exchange solved my problem in a way :slight_smile:

Check your browser console. Most browsers have that by clicking right button on your page, then select “Inspect”. In the console you will see errors. I am pretty sure something along the lines of CSP will come up or something like “not found”. The empty head/body tags are a workaround of your browser to show “nothing”.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.