X
Embed an X post in your content using the x shortcode.
New in
v0.141.0To override Hugo’s embedded x
shortcode, copy the
source code to a file with the same name in the layouts/shortcodes
directory.
Example
To display an X post with this URL:
https://x.com/SanDiegoZoo/status/1453110110599868418
Include this in your Markdown:
{{< x user="SanDiegoZoo" id="1453110110599868418" >}}
Rendered:
Owl bet you'll lose this staring contest 🦉 pic.twitter.com/eJh4f2zncC
— San Diego Zoo Wildlife Alliance (@sandiegozoo) October 26, 2021
Privacy
Adjust the relevant privacy settings in your site configuration.
privacy:
x:
disable: false
enableDNT: false
simple: false
[privacy]
[privacy.x]
disable = false
enableDNT = false
simple = false
{
"privacy": {
"x": {
"disable": false,
"enableDNT": false,
"simple": false
}
}
}
- disable
- (
bool
) Whether to disable the shortcode. Default isfalse
. - enableDNT
- (
bool
) Whether to prevent X from using post and embedded page data for personalized suggestions and ads. Default isfalse
. - simple
- (
bool
) Whether to enable simple mode. Iftrue
, Hugo builds a static version of the of the post without JavaScript. Default isfalse
.
The source code for the simple version of the shortcode is available here.
If you enable simple mode you may want to disable the hardcoded inline styles by setting disableInlineCSS
to true
in your site configuration. The default value for this setting is false
.
services:
x:
disableInlineCSS: false
[services]
[services.x]
disableInlineCSS = false
{
"services": {
"x": {
"disableInlineCSS": false
}
}
}
Last updated:
February 17, 2025
:
all: Change shortcode usage and design to prevent invalid HTML (0fca8ef25)
Improve this page