The whole embed reconstructs from one string in the URL
Embedding Spotify in Hugo, and why a shortcode beats the iframe you copied.
Hugo ships shortcodes for YouTube, Vimeo, X, Instagram and gists. Not Spotify. So an embed is either raw HTML or something I write.
What I spotted
-
I spent a while trying to move a copied iframe around before noticing that the entire thing reconstructs from one string:
open.spotify.com/album/6mnGRO87UFiKOoHL3BezZ7?si=abc123 ^type ^------- the id -------^ ^tracking -
That
?si=is share-tracking. -
It isn’t part of the address and it doesn’t belong in a published page.
The entire embed rebuilds from one string in a share link.
The shortcode
-
Everything else — the width, the allow list, the frame border — is boilerplate I can generate. So:
Why it only pays on the second embed
- The argument for the shortcode only really shows up on the second embed.
- Spotify’s copied markup hardcodes
border-radius:12pxand a fixed height, so paste two and they disagree with each other and with the theme. - A shortcode picks the height from the type — 352 for a track, 452 for an album — and the styling stays in one file where I can change my mind about it once.