YouTube embeds not working with certain video ID codes

I’m applying the shortcode but it seems that due to the inclusion of an underscore at the beginning of the video ID it won’t work.

https://youtu.be/_IUHMuBH788​

{{< YouTube _IUHMuBH788​ >}}

I tried a backslash in front of the underscore, but that didn’t work, either. Also, do the spaces in the shortcode matter and if so, where do they go?

Thanks!

I think the issue is YouTube versus youtube.

This is using a built in Hugo feature, nothing Micro.blog related Shortcodes | Hugo

I thought that as well and corrected the auto correct and no change. In working shortcodes in the editor the brackets are recognized with color coding. With the leading underscore on this id the closing bracket does not. Good idea though. Thanks :slight_smile:

Sounds like a Hugo bug then.

1 Like

For some reason the term is not coming to me but can I not use a “\” to tell the editor to not render the following character?

I don’t think this has anything to do with the editor itself, if Hugo isn’t producing the shortcode right and that is valid syntax, then I think the shortcode itself has a bug. You may be able to wrap it in quotes. eg. {{< youtube "_IUHMuBH788" >}} I’m not 100% on that.

I can give that a go thanks :blush:

Nope. That didn’t work. I created an Apple Shortcut automation to take the clipboard, in this case the Video ID, and insert into a Hugo shortcode and send that back to the clipboard for pasting into Micro.blog.

image

So, I think I know what the problem is. As the editor is evaluating markdown, it’s disrupting the Hugo shortcode when an underscore appears in the Video ID. As you can see, the close bracket isn’t recognized in the correct Video ID, but if I remove the underscore and eliminate the space between the end of the ID and the close bracket, it is matched, though this also invalidates the Video ID and it won’t go to anything.

Not sure how to get around this with the editor or Hugo.

I successfully used this short code. You need to use a straight quote and not a curly quote.

{{< youtube "_IUHMuBH788​" >}}

works.

Straight codes as required, as using an underscore notes the following in the logs:

Error: error building site: assemble: “content/2024/08/20/test-youtube-iuhmubh.md:1:1”: unrecognized character in shortcode action: U+200B. Note: Parameters with non-alphanumeric args must be quoted’’

See


1 Like

Ok. Thank you! Where do you find those logs? The same as in the sources page? Sorry. I’m just a writer and not code savvy :slight_smile:

Logs

1 Like

The U+200B in the log makes me think this is an editor problem after all, because that’s an invisible character (zero-width space) that the editor uses. That should be completely stripped out so something must be wrong. Looking into it, thanks y’all.

1 Like

Confirming, there’s a bug that I’m fixing now. Should be live shortly.

2 Likes