X shortcode
Usage
The x shortcode embeds the X post with the given user name and ID. Both values appear in the post’s URL. For example, the user name of the post at https://x.com/SanDiegoZoo/status/1453110110599868418 is SanDiegoZoo, and the ID is 1453110110599868418.
Adjust the privacy settings for this shortcode in your project configuration. These are the default settings:
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 post without JavaScript. Default isfalse.
In simple mode, Hugo adds inline CSS to style the post. To remove the inline CSS, set disableInlineCSS to true in your project configuration. These are the default settings:
services:
x:
disableInlineCSS: false
[services]
[services.x]
disableInlineCSS = false
{
"services": {
"x": {
"disableInlineCSS": false
}
}
}
To override Hugo’s embedded x shortcode, copy the source code to a file with the same name in the layouts/_shortcodes directory. To override simple mode, also copy the simple mode source code.
Arguments
The x shortcode accepts named arguments.
id- (
string) The ID of the X post. Required. user- (
string) The user name of the account that published the post. Required.
Examples
{{< x user="SanDiegoZoo" id="1453110110599868418" >}}Your browser displays this:
Owl bet you'll lose this staring contest 🦉 pic.twitter.com/eJh4f2zncC
— San Diego Zoo Wildlife Alliance (@sandiegozoo) October 26, 2021
