Hugo shortcode for embedding Unity WebGL players – updated with code

02 July 2021 webdev gamedev

Want to embed Unity WebGL players easily inside your Hugo website? Here’s a shortcode for you.

I wanted to embed my Unity WebGL builds inside this site, rather than linking to the content in a new tab (which is over in Azure blob storage). This lets me do that.

Code

Code is available here: https://github.com/cassidymichael/hugo-shortcode-unity-webgl.

Example usage

{{< unity-webgl-player 
    gameTitle="My cool game"
    width="1024" 
    height="576"
    buildURL="https://somewhere.com/path/to/files/Build" 
    buildFileName="webgl"
    playerID=""  >}}

Demo

Embedding the first ever game I made:

This content does not resize on smaller browser widths. Try using the fullscreen button below (after loading the game).
WebGL builds are not supported on mobile devices.

I hope this helps someone!

Issues/comments/improvements/etc welcome 😄

comments powered by Disqus