> ## 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.

# Hashtag Button

> A Hashtag button is a special type of Post button to encourage participation in a conversation grouped by keyword. Read more about hashtags on X.

A Hashtag button is a special type of [Post button](/x-for-websites/post-button/overview) to encourage participation in a conversation grouped by keyword. [Read more about hashtags on X](https://support.x.com/articles/49309).

## How to add a Hashtag Button to your website

1. Create a new anchor element with a `twitter-hashtag-button` class to allow the X for Websites JavaScript to discover the element and enhance the link into a Hashtag 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-hashtag-button"
  href="https://x.com/intent/tweet">
Post</a>
```

2. Add your hashtag of interest as a `button_hashtag` query parameter value and a component of the anchor element’s inner text.

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

3. 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 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.

## Define secondary hashtags

Include additional hashtags in pre-populated Post text using the [hashtags web intent query parameter](/x-for-websites/post-button/guides/web-intent). A hashtag defined in the `button_hashtag` parameter and displayed in the button will appear before hashtags defined in the `hashtags` parameter.

## JavaScript factory function

X's widget JavaScript library supports dynamic insertion of a hashtag button using the `twttr.widgets.createHashtagButton` function. Pass a hashtag, target container element, and the same options supported by the [Post button JavaScript factory function](/x-for-websites/post-button/guides/javascript-factory-function).

```javascript theme={null}
twttr.widgets.createHashtagButton(
  "XStories",
  document.getElementById("container"),
  {
    size:"large"
  }
);
```
