[SOLVED] Self-created shortcode breaks Vimeo/Youtube shortcode

Hello,
I created shortcodes for vimeo, youtube, and soundcloud.
I know that the vimeo and youtube shortcodes are built in, and just formatted them according to my needs (I want to show video and audio embeds in fancybox).

So the shortcode in vimeo.html looks like this:

href=“https://player.vimeo.com/video/{{ .Get 0 }}” name="{{ .Get 1 }}" data-fancybox data-type=“iframe”> {{ .Get 1 }}

and call it in a post with

{{< vimeo 226888246 Plastic_Girls >}}

and everything works fine.

But when I try the the same for soundcloud,

href=“https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/{{ .Get 0 }}” name="{{ .Get 1 }}" data-fancybox data-type=“iframe”> {{ .Get 1 }}

and call it with e.g.

{{< soundcloud 343118668&amp Vakula >}

on the website, all shortcodes including the youtube and vimeo ones don’t appear as links, but are written out as in the markdown file. So I just get a list of these

{{< vimeo 226888246 Plastic_Girls >}}

{{< soundcloud 343118668&amp Vakula >}

Hm… any ideas as to why that is, and how to fix it?
Thanks!

Nothing pops out to me. Are your site’s hugo layouts available online to look at?

Thanks for looking into it… since I am fairly new to all this and am not sure what you would look for, I shoved all the files to here.
Much appreciated~!

That shortcode is missing a closing curly brace. But also, it has an ampersand in the parameter. That must be quoted. I know that, because it said so in the log:

Change detected, rebuilding site
2017-09-27 12:06 -0700
Source changed "/home/maiki/projects/temp/bbs-web/content/col2-text.md": RENAME
Source changed "/home/maiki/projects/temp/bbs-web/content/col2-text.md": CREATE
Source changed "/home/maiki/projects/temp/bbs-web/content/col2-text.md": WRITE
ERROR 2017/09/27 12:06:22 col2-text.md:21: unrecognized character in shortcode action: U+0026 '&'. Note: Parameters with non-alphanumeric args must be quoted
ERROR 2017/09/27 12:06:22 col2-text.md:21: unrecognized character in shortcode action: U+0026 '&'. Note: Parameters with non-alphanumeric args must be quoted
ERROR 2017/09/27 12:06:22 col2-text.md:21: unrecognized character in shortcode action: U+0026 '&'. Note: Parameters with non-alphanumeric args must be quoted

I quoted it and it began working:

{{< soundcloud "343118668&amp" Vakula >}}

Changing content and checking the log to see errors is the first step to debugging a template. :slight_smile:

2 Likes

Oops… hehe… it looks like keeping an eye on the logs is a good idea –.–;; . The Hugo mystery is solved, but the quotes also prevent the link from directing to soundcloud properly.

Ironically what worked is placing the &amp part in the shortcode itself, and just use the numerical part of the track id in the post, so I can avoid the quoting. I didn’t realize before that the &amp is in all soundcloud embed links .

Anyway, thanks so much for you help, it works smoothly now!