I was wondering if there was a way to “embed a tweet” into a post.
I know that embedding in general is possible, via Hugo shortcodes: using {{< youtube ... >}} works.
However, using the {{<tweet user="..." id="..." >}} shortcode doesn’t; the failure is having something like HAHAHUGOSHORTCODE-0xc000e7f900-1-HBHB show up in the rendered output.
So, Is this something that’s supposed to work?
(Has anyone ever embedded a tweet? Is there a reason why shortcodes are treated differently?)
I embedded a tweet successfully just now. So it’s supposed to work.
However, how you use the shortcode differs depending on the Hugo version. You can see your blog’s version by navigating to Design and looking for the label Hugo version.
Embed a tweet using Hugo 0.54:
{{< tweet 20 >}}
Embed a tweet using Hugo 0.91:
{{< tweet user="Jack" id="20" >}}
Doing the above ended up looking like this on my test blog:
Hi! This is an only somewhat related follow up question. If I need to start a new thread, please let me know.
I’m trying to embed something from Apple Music. I’ve found blog posts, etc. related to creating a custom shortcode. Would I need to do that in order to embed Apple Music stuff? Is that even possible to do with micro.blog?
Yes, pasting in the Apple Music embed code should work fine in a Micro.blog blog post. Note that the full iframe tag is not supported in the Micro.blog timeline, so instead Micro.blog will try to make it a link to Apple Music. But on your actual microblog on the web it will look correct.
was working fine for a while with Hugo 0.91 default theme. Now it’s failing with errors.
Theme error: Error building site: “/rym_1e3793/content/2022/12/16/usertorriangray-id-this.md:9:1”: failed to extract shortcode: template for shortcode “user” not found
It’s hard to help you without seeing the actual content of your post. But the error message you share indicates your source looks like this (without tweet):
@sod is almost definitely correct, but I also want to warn about using the Twitter shortcode (which I like and have used as well!): if the user deletes their account or the tweet is deleted, it will cause a build error. With more people fleeing twitter, this has become more common and is something to consider.
Agree with Sven and Jason. I started using Quotebacks for tweets, because I ran into Hugo build errors and had to go through hundreds of posts to find the ones with embedded tweets and take them out.
I’ve never had an issue with using shortcodes for embedded YouTube videos, though, which is good because their iframe embeds are not responsive.