Embed twitter and youtube
By Daniel Durling in R Website
August 12, 2021
POC on how to emed youtube and twitter
Here is a short example of how to embed a YouTube into your blogdown & Hugo blog.
YouTube
To embed a YouTube video in an R Markdown document you need to write this:
I will be embedding this video of Hadley Wickham talking at UCL (which I was lucky enough to attend).
All you need to do is use Hugo short code and then the video name:
{{< youtube vYwXMnC03I4 >}}
(in order to display the above rather than call the shortcode I had to add a \
before the <
and then >
to stop them being special characters.).
Here is what it looks like when we call the shortcode:
In the blog I was following it said you needed to use %…% rather than <…> but I found that both worked so I have two copies of the video embedded in my site.
To embed a tweet is very similar, use the same Hugo short code but replace YouTube with tweet. This tweet from Hadley Wickham about his new book on mastering shiny seems like a good candidate:
Mastering Shiny has just gone into production🎉, so now's a great to pre-order if you want a physical copy! https://t.co/r5BnEMiOBd (Or continue to read online for free at https://t.co/aby9kfwmQu) #rstats pic.twitter.com/PKNvsIHFxJ
— Hadley Wickham (@hadleywickham) April 29, 2021
There we go!
The full list of available Hugo short-codes are here and you can also add your own custom ones too 9I need to look into that, the blog I linked to above has a post on it I think).