> ## Documentation Index
> Fetch the complete documentation index at: https://docs.x.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Post button

> Add a Post button to your website with HTML markup and widgets.js to let visitors share content on X with pre-populated text, hashtags, and via attribution.

The Post button is a small button displayed on your website to help viewers easily share your content on X. A Post button consists of two parts: a [link to the Post composer on x.com](/x-for-websites/post-button/guides/web-intent) and X for Websites JavaScript to enhance the link with the easily recognizable Post button.

The [publish.x.com](https://publish.x.com) website provides a simple, form-based approach to generate HTML markup for a Post button you may copy-and-paste into your website template.

A [post event](/x-for-websites/javascript-api/guides/javascript-api) is triggered on your webpage when the Post button is tapped or clicked.

## How to add a Post button to your website

1. Create a new anchor element with a `twitter-share-button` class to allow the X for Websites JavaScript to discover the element and enhance the link into a Post button. Set a `href` attribute value of `https://x.com/intent/tweet` to create a link to the X web intent composer.

```html theme={null}
<a class="twitter-share-button"
  href="https://x.com/intent/tweet">
Post</a>
```

2. Pre-populate Post text and suggest related accounts by customizing [Post web intent](/x-for-websites/post-button/guides/web-intent) query parameters.

```html theme={null}
<a class="twitter-share-button"
  href="https://x.com/intent/tweet?text=Hello%20world">
Post</a>
```

3. Customize [Post button parameters](/x-for-websites/post-button/guides/parameter-reference) using `data-*` attributes.

```html theme={null}
<a class="twitter-share-button"
  href="https://x.com/intent/tweet?text=Hello%20world"
  data-size="large">
Post</a>
```

4. Asynchronously [load the X for Websites JavaScript using our loading snippet](/x-for-websites/javascript-api/guides/set-up-x-for-websites). The JavaScript snippet will check for an existing version already on the page, initialize a function queue to be executed once the widgets JavaScript has loaded, and load the widgets JavaScript asynchronously from X’s CDN.

## Post text components

### text

A `text` parameter appears pre-selected in a Post composer. The Post author may easily remove the text with a single delete action.

The `text` parameter may be auto-populated from the webpage’s `<title>` element if not explicitly set.

### url

The `url` parameter contains an absolute HTTP or HTTPS URL to be shared on X. The shared URL will be [automatically shortened](https://support.x.com/articles/78124-how-to-post-shortened-links-urls) in a published Post. A [Card](https://dev.x.com/cards/overview) may appear for a shared URL.

The `url` parameter may be auto-populated from a [canonical link element](http://en.wikipedia.org/wiki/Canonical_link_element) (`<link rel="canonical">`) or the [location.href](https://html.spec.whatwg.org/multipage/browsers.html#the-location-interface) of the page when not explicitly set.

```html theme={null}
<link rel="canonical"
  href="/web/tweet-button">
```

### hashtags

Add a comma-separated list of `hashtags` to a Post using the `hashtags` parameter. Omit a preceding “#” from each hashtag; the Post composer will automatically add the proper space-separated hashtag by language.

### via

Attribute the source of a Post to a X username using the `via` parameter. The attribution will appear in a Post as ” `via @username`” translated into the language of the Post author.

A `via` parameter may be auto-populated from a link or anchor element linked to a X profile page with a `me` relationship token.

```html theme={null}
<link rel="me"
  href="https://x.com/XDevelopers"
>
```

## Button customization

### Size

Add a `data-size` attribute value of `large` to display a larger Post button.
