Video on Front Matter

Is there any way that i can use front matter to access video ?

Front Matter :
+++
gomo = “https://gomoplayer.com/embed-ux0v6bjqxlfs.html
+++

On single.html :

{{ with .Params.gomo }}< video src="{{ . }}" > {{ end }}

it’s returned blank

Try using the safeHTMLAttr function.
e.g. <video src="{{ . | safeHTMLAttr }}">

Long story short: Go templates as a security precaution, sometimes do not accept HTML attributes without an explicit declaration that these are safe.

Also have a look at the other safe Hugo functions in the Docs.

If the above does not fix the issue, then please provide a repo with a sample project that reproduces the issue for people in this forum to have a look.

Just in case you all are NOT doing the space behind the tag thingy for layout or formatting issues: That’s an error. HTML tags require a bracket (<) to be immediately followed by the tag name, no spaces allowed.

1 Like

I didn’t really pay attention to the wrong HTML above. Of course if I was working in an actual template in my editor with its lint, I would certainly have noticed. :upside_down_face:

I think i find solution :

{{ with .Params.gomo }}
< iframe src="{{ . | safeHTMLAttr }}" width="100%" height="500" ></iframe>
{{ end }}

Modified as Iframe not video is good on my end, thanks @alexandros @davidsneighbour

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