| 1 |
--- |
| 2 |
title: X shortcode |
| 3 |
linkTitle: X |
| 4 |
description: Embed an X post in your content using the x shortcode. |
| 5 |
categories: [] |
| 6 |
keywords: [] |
| 7 |
--- |
| 8 |
|
| 9 |
{{< new-in 0.141.0 />}} |
| 10 |
|
| 11 |
> [!NOTE] |
| 12 |
> To override Hugo's embedded `x` shortcode, copy the [source code][] to a file with the same name in the `layouts/_shortcodes` directory. |
| 13 |
|
| 14 |
## Example |
| 15 |
|
| 16 |
To display an X post with this URL: |
| 17 |
|
| 18 |
```txt |
| 19 |
https://x.com/SanDiegoZoo/status/1453110110599868418 |
| 20 |
``` |
| 21 |
|
| 22 |
Include this in your Markdown: |
| 23 |
|
| 24 |
```md |
| 25 |
{{</* x user="SanDiegoZoo" id="1453110110599868418" */>}} |
| 26 |
``` |
| 27 |
|
| 28 |
Rendered: |
| 29 |
|
| 30 |
{{< x user="SanDiegoZoo" id="1453110110599868418" >}} |
| 31 |
|
| 32 |
## Privacy |
| 33 |
|
| 34 |
Adjust the relevant privacy settings in your project configuration. |
| 35 |
|
| 36 |
{{< code-toggle config=privacy.x />}} |
| 37 |
|
| 38 |
`disable` |
| 39 |
: (`bool`) Whether to disable the shortcode. Default is `false`. |
| 40 |
|
| 41 |
`enableDNT` |
| 42 |
: (`bool`) Whether to prevent X from using post and embedded page data for personalized suggestions and ads. Default is `false`. |
| 43 |
|
| 44 |
`simple` |
| 45 |
: (`bool`) Whether to enable simple mode. If `true`, Hugo builds a static version of the of the post without JavaScript. Default is `false`. |
| 46 |
|
| 47 |
The source code for the simple version of the shortcode is available [in this file][]. |
| 48 |
|
| 49 |
If you enable simple mode you may want to disable the hardcoded inline styles by setting `disableInlineCSS` to `true` in your project configuration. The default value for this setting is `false`. |
| 50 |
|
| 51 |
{{< code-toggle config=services.x />}} |
| 52 |
|
| 53 |
[in this file]: <{{% eturl x_simple %}}> |
| 54 |
[source code]: <{{% eturl x %}}> |