BlogSocial Media FeedsUGC

How to Embed a Twitter (X) Feed in HTML (2027 Code + Examples)

Embed a Twitter (X) feed in HTML with the current X code, fix blank timelines, and see live X feed examples. Copy-paste snippet inside.

Last updated: Dushko Talevski
View as Markdown
Twitter (X) feed embed code in HTML turning into a live X feed on a website
Dushko Talevski

Dushko Talevski

Content Writer & Editor at EmbedSocial

To embed a Twitter feed in HTML, generate the timeline code at publish.x.com and paste it where the feed should appear. It takes about two minutes.

The catch: X changed the embed code after the rebrand. Most tutorials still show the old twitter.com version. Below you’ll find the current code, the fixes for a blank timeline, and a no-code option for when the native widget isn’t enough.

TL;DR: the Twitter (X) timeline embed code

Paste this into your page’s HTML, replace yourusername with your handle, and publish:

<a class="twitter-timeline" href="https://x.com/yourusername">Posts by yourusername</a>
<script async src="https://platform.x.com/widgets.js" charset="utf-8"></script>

Embed a Twitter (X) feed in HTML with X Publish

X’s free tool, X Publish, creates the Twitter timeline embed code for two kinds of timelines: a profile timeline (posts from one public account) and a List timeline (posts from a public X List). You don’t need an API key or a developer account.

Hashtag, search, likes and collection timelines no longer exist. X retired them, so any tutorial that still offers them is out of date.

How to choose a Twitter (X) embed method: single post, timeline, or EmbedSocial widget

1. Go to publish.x.com

Open https://publish.x.com/ in your browser. The old address, publish.twitter.com, now redirects there.

X Publish home page with the field for the X URL you want to embed

2. Paste your X profile or List URL

Paste the URL of a public profile (for example https://x.com/yourusername) or a public List, then press Enter. The account must be public: posts from protected accounts can’t be embedded.

X Publish URL field with a link to an X post

3. Choose “Embedded Timeline”

Pick Embedded Timeline from the display options to embed the Twitter timeline. It’s live: new posts appear on your site automatically.

Embedded Timeline and X Buttons options in X Publish

4. Set the height and theme

Click set customization options to choose the height, a light or dark theme and the language. Click Update to apply them to the code.

X Publish customization options for timeline height, theme and language

5. Copy the HTML snippet into your page

Click Copy Code and paste the snippet inside your page’s <body>, exactly where the feed should appear. X’s script turns the link into a scrolling timeline when the page loads.

X Publish showing embed code and the Copy Code button for a single X post

X Publish confirming the HTML snippet was copied

Twitter feed embed code: copy-paste snippets

Rather skip X Publish? Copy the Twitter feed embed code below and replace the placeholders with your own handle, List or post.

The four parts of the Twitter (X) timeline embed code: link, options, fallback text and script

Profile timeline embed code

Shows the latest posts from one public account:

<a class="twitter-timeline" href="https://x.com/yourusername">Posts by yourusername</a>
<script async src="https://platform.x.com/widgets.js" charset="utf-8"></script>

X List timeline embed code

Shows posts from every account in a public List. Copy the List URL from x.com (it may look like https://x.com/i/lists/123456789). X Publish can return the List URL with the owner’s handle and List name:

<a class="twitter-timeline" href="https://x.com/yourusername/lists/your-list">Posts from our List</a>
<script async src="https://platform.x.com/widgets.js" charset="utf-8"></script>

Single post embed code

To show one post instead of a timeline, paste the post URL into publish.x.com. The code it returns looks like this (simplified):

<blockquote class="twitter-tweet"><a href="https://x.com/yourusername/status/POST_ID"></a></blockquote>
<script async src="https://platform.x.com/widgets.js" charset="utf-8"></script>

A single post is static: good for blog posts, case studies and launch pages. A timeline is dynamic: it keeps the page fresh as you post, but it adds more design and speed considerations.

Timeline embed attributes

The Twitter widget HTML accepts a few data- attributes on the <a> tag:

Attribute What it does Example
data-height Sets the height in pixels; the timeline scrolls inside it data-height="600"
data-width Sets a maximum width (by default it fills the container) data-width="400"
data-theme Switches between the light and dark theme data-theme="dark"
data-tweet-limit Shows a fixed number of posts (1 to 20) with no scrolling data-tweet-limit="5"
data-chrome Hides parts of the frame: noheader, nofooter, noborders, transparent, noscrollbar data-chrome="noheader nofooter"

Test every attribute on a staging page first. X changes widget behavior without notice. If you use noheader, X requires you to credit X and link to the original timeline.

Need hashtags, mentions or more than one account? EmbedSocial pulls them into one widget you design yourself. X accounts start on Pro Plus. Hashtags, mentions and keywords are on Premium.

Add the Twitter feed HTML to your website builder

The Twitter feed HTML is the same everywhere. What changes is where your builder lets you paste HTML and whether it keeps the <script> tag.

Static HTML site

Paste the snippet into the page file where the feed should appear, save it and upload it. If the page already loads widgets.js once, you don’t need the <script> line twice.

WordPress

Add a Custom HTML block and paste the code. Some security plugins strip scripts; if you only see a link, check fix 1 below. For moderation and custom layouts, use the X (Twitter) widget for WordPress.

Shopify

In the theme editor, add a Custom Liquid section to the template and paste the code. For a styled feed on product pages, see the X feed on Shopify.

Wix

Click Add Elements > Embed & Social > Embed code, then Enter Code, paste it and click Update. More options: X feed on Wix.

Squarespace

Add a Code block, paste the snippet and save. More options: X feed on Squarespace.

Using another builder? The step-by-step for more builders is in our post on how to embed a Twitter feed or X timeline.

Twitter (X) embed not working? 7 fixes

Most tutorials stop at the snippet. These are the problems that show up on real sites, and the fix for each one:

The widgets.js script didn’t run. Your builder stripped the <script> tag, a privacy extension blocked platform.x.com, or JavaScript is off. On React, Vue and other single-page apps, call window.twttr.widgets.load() after the embed is added to the page.

2. The timeline is blank for some visitors

This one is on X’s side. Developer forum reports show timelines loading empty for logged-out visitors or during rate limits. Your code can’t fix it; a widget that syncs posts on its own servers, like EmbedSocial, avoids the dependency.

3. Hashtag, likes or search timelines won’t load

X retired them. Only profile and List timelines work. For a hashtag or mentions feed, use an X hashtag feed template in EmbedSocial (Premium plan) or follow our post on how to embed a Twitter hashtag feed.

4. The layout looks broken on mobile

Almost always a fixed width or a CSS conflict. Remove data-width, let the parent container run 100% wide, and turn off custom styles one by one to find the clash.

5. You can’t embed a private account

Only public accounts work. Protected posts aren’t compatible with any X embed, native or third-party.

6. Your page speed drops

The timeline loads X’s script plus an iframe. Place it below the fold, load the script once per page and keep the async attribute. EmbedSocial’s AI UGC widgets lazy-load by default.

7. Your Content Security Policy blocks X

If your site sends a strict CSP header, allow platform.x.com, platform.twitter.com and syndication.twitter.com in script-src and frame-src. Otherwise the feed won’t render even when the HTML is correct.

Limits of the native X embed

The native widget is built for quick sharing, not for control:

If all you need is a feed in a sidebar, that’s fine. To add a Twitter feed to your website as a branded, moderated section, use a widget.

Embed an X feed without code using EmbedSocial

Instead of pasting X’s script, connect your account to the X (Twitter) widget and let it sync new posts into a widget you design. It’s the fastest way to embed an X feed on your website with moderation and your own branding.

X accounts start on the Pro Plus plan; hashtags, mentions and keywords are on Premium (see EmbedSocial plans). First, create your EmbedSocial account. Then:

1. Describe your X (Twitter) website widget

Describe your ideal X widget in the AI Widget Builder and click Generate. It uses one AI credit.

Describing an X (Twitter) widget in the EmbedSocial AI Widget Builder

2. Connect your X (Twitter) account as the source

Open the Sources tab and connect an X (Twitter) source. Pick @Account for your own posts, or #Hashtag, @Mentions or Keywords on Premium.

Connecting an X (Twitter) account as a source in EmbedSocial

3. Select a layout template for your Twitter feed

Choose a ready-made template (grid, slider, wall or popup) or an AI template you can keep refining with prompts.

Choosing a layout template for an X (Twitter) feed widget in EmbedSocial

4. Adjust the design and settings of your X (Twitter) widget

Describe the change you want, such as colors, layout or spacing, and the editor updates the design.

Customizing the design of an X (Twitter) widget with a prompt in EmbedSocial

5. Copy the generated embed code

Open the Embed tab and click Copy code.

Copying the X (Twitter) widget embed code from the EmbedSocial Embed tab

6. Insert the code into your website

Add an HTML block in your site builder, paste the code and publish. The docs show how to embed your widget on any website. The result looks like this:

You control what appears: approve or hide posts, filter by hashtag, combine several X accounts in one feed, or merge X with Instagram in one social media wall.

EmbedSocial features for Twitter (X) feeds

X hashtag, mention and keyword sources

Go beyond your own profile: collect posts that use your hashtag, mention your handle or contain a keyword. Hashtag, mention and keyword sources are on Premium. Setup: X (Twitter) source docs. For mentions across X, see X social listening.

Moderation

Approve or hide posts before they go live. Learn how to moderate your X feed.

Tagging

Tag posts manually or with AI, then filter by tag. See the tagging docs.

Multi-source social walls

Combine X with Instagram, TikTok, YouTube and reviews in one feed using the social media aggregator. Setup: connect a source.

Native X embed vs EmbedSocial

Here’s where the distinction becomes strategic:

Feature Native X embed EmbedSocial
Sources One profile or List timeline X accounts, hashtags, mentions and keywords
Branding control Light/dark theme and height only Full customization
Moderation No Yes, manual moderation
Multi-account feeds No Yes
Cross-platform aggregation No Yes, X plus Instagram, TikTok, reviews and more
Layout One vertical timeline Grid, slider, wall and popup templates
Reliability Depends on X; can load blank for some visitors Posts synced into EmbedSocial and shown by its widget
Plan Free X accounts from Pro Plus; hashtags, mentions and keywords on Premium

If you need something quick and disposable, native works.

If you’re building a brand asset, automation and control matter.

Twitter (X) feed examples you can see live

These are live EmbedSocial templates, so you can open each one and watch the feed work. Each fits a different job on your site.

X feed widget grid: product updates on a SaaS homepage

A clean X feed widget in a card grid. Put it under your homepage hero to show shipping updates, customer replies and founder posts: proof that the product is alive. Open the live X feed grid.

X feed widget in a card grid layout showing recent Twitter posts on a website

Classic X slider: social proof on product pages

A light card slider that takes little vertical space. Use it on product or pricing pages to show what customers say about you on X, next to the buy button. Open the live classic X slider.

Classic X (Twitter) slider widget with post cards on a product page

Modern X slider: founder-led brands and launches

A dark-mode carousel built for launch pages and personal brands, where your own posts are the content. Open the live modern X slider.

Dark mode X (Twitter) carousel widget showing the latest posts from an account

X hashtag feed: event and campaign pages

Collects posts with your event or campaign hashtag into one live feed. Visitors see real attendee reactions while the event runs. Open the live X hashtag feed.

Classic X (Twitter) hashtag feed template with a grid of posts

X mentions popup: agency and consultant sites

A small floating popup with recent mentions of your handle. Select the launcher to open the feed. It keeps client praise visible on every page without adding a full section. Open the live X mentions popup.

Closed launcher for the X (Twitter) mentions popup widget

More layouts: browse all X feed templates or get ideas from these social wall examples.

Why embed an X feed: 5 expert takes

We asked marketers and founders what embedding X content did for their sites. Five answers stood out:

Embedded UGC lifts onsite trust and conversions

When you link to X, you’re essentially purchasing traffic but redirecting it back to the place from which it originated. Our findings show that embedding content keeps the user inside of your ecosystem while providing a “real time” signal as opposed to a static website. This will create an increase in the levels of credibility because users can see the interaction that is occurring in real time, and thus have a base for measuring the authenticity of the interaction, which is much harder to fake than a traditional testimonial block.

Therefore, the biggest win for user generated content (UGC) is the increase in conversion rates as a result of the UGC. Nosto has found that UGC can increase conversion rates on the web by up to 29%, and we have seen time and again how the live feed UGC acts as a trust bridge and validates that the brand is presently active and responsive. The measurable result is that it validates your claims based on real-user-generated content from the voices of the community instead of just using your own marketing material. Just be aware of the technical side of this; if the embed is not optimized, then page load speed will be negatively affected, which will diminish any benefit to your SEO from using social proof to increase sales.

Digital trust building is an ongoing fight against skepticism in marketing. Having an unfiltered, real-time, digital feed of community activity acts as a proof point showing you have nothing to hide. It provides the opportunity to turn one-way marketing messages into two-way conversations that occur at the same point as the transaction.

Amit Agrawal, Founder & COO, Developers.dev

-——————————————

Embedded X cuts time to purchase 17%

Embedding X on our website reduced the time between the first product page visit and purchase by 17%. We noticed a pattern where users started by visiting our Product Page. They then went to the FAQ section, read a few blogs, saw the coverage map and exited the website.

Considering travel connectivity buyers don’t shop emotionally, their hesitation was about uncertainty. Will the SIM activate immediately and how well will it work in rural areas? What happens if my flight is delayed?

The information on our blog and resource section answered these questions in rigid copies that read like policy. What we posted on X and the comments from our customers clarified their doubts. The time to conversion dropped by 17% as customers made faster decisions. We also noticed they stopped looking for more information beyond our FAQ and website.

Oleksii Sosnovenko, Digital Marketer, Mobal

-——————————————

Embed social to keep visitors focused

Embed X content on your website to keep visitors focused on the content and context of their visit. Providing an external link to a social network diverts a client’s attention from the content on your site to everything else on the Internet. By embedding, the conversation will remain on your site and you can be assured that clients are engaging with content relevant to the business.

Therefore, integrate social conversations to ensure that feedback supports the overall message you want to convey, rather than being located separately on a social media platform.

I believe the inclusion of embedded content causes visitors to spend more time on the site and allows them to interact with the content in a structured manner. From a marketing perspective, I believe it provides a simple method to create a single source of visibility, thought leadership, and messaging.

John Karsant, Founder and CEO, LevelUp Leads

-——————————————

X embeds build trust and spark engagement

Embedding Twitter (X) content brings one of the most important aspects, trust and credibility. Earlier, without embedding Twitter posts within the content, viewers had to leave the current tab and switch to social media platforms for social proof. 

By including external social media links, people can get live reactions and comments without even leaving the browsing screen. This also increased the longer stay time on the page, highlighting that the current traffic perceives the content as a value-added thing. 

While we have learnt from our clients that people like the transparency of social proof, this also naturally pushes the audience to engage by commenting and reacting. Again, this is a win-win thing, or what I might call hitting two birds with a single arrow. In simple words, this also brings in higher engagement on social media platforms.

Tyler Denk, Co-founder & CEO, beehiiv

-——————————————

Live feeds lift time on page and leads

When you embed live Twitter (X) content on your website, it builds trust with your visitors and encourages them to spend more time on your site rather than driving them to other sites. A good way to do this is to show the visitor the live, current conversations from your customer base, via live posts, reviews, or hashtag conversations about your business on all of your important landing pages as well as creating instant, visual credibility.

Embedding a live customer hashtag feed on high-intent product pages caused an increase in time spent on those pages of greater than 20%, and a 15% increase in inquiries submitted through the online inquiry form. Customers were able to engage with the authentic user-generated content without having to leave the site; therefore, the bounce rate was decreased, and the length of the decision cycle was also decreased. 

Real customers’ public postings of their own experiences showed the same level of transparency that static testimonials cannot provide. So here’s what we have learned so far: keep your social proof on your website. Embedded live feeds can build credibility, cause measurable increases in engagement, and convert passive viewers into active leads without losing traffic to external sites.

Kellon Ambrose, Managing Director, Electric Wheelchairs USA

-——————————————

Social proof works best when it’s next to the decision. See more social proof examples and testimonial examples, or how to embed Twitter reviews.

Conclusion: Embed your X feed the right way

To embed a Twitter feed in HTML, the current X code gets you live in minutes: copy it from publish.x.com, paste it into your page and check the seven fixes if it stays blank.

If you need hashtags, mentions, moderation or a design that matches your site, move from a raw script to a managed feed. A UGC platform like EmbedSocial turns your X posts into a structured, conversion-ready section that keeps itself up to date.

Frequently asked questions

How do I embed a Twitter feed in HTML without plugins?

Go to publish.x.com, paste your profile or List URL, choose Embedded Timeline and paste the code into your page’s HTML. No plugin is needed. For moderation and custom design without code, use EmbedSocial instead.

What is the Twitter HTML code for a timeline?

<a class="twitter-timeline" href="https://x.com/yourusername">Posts by yourusername</a> followed by <script async src="https://platform.x.com/widgets.js" charset="utf-8"></script>. Replace yourusername with your handle.

Can I embed a Twitter hashtag feed in HTML?

Not with X’s native tools: X retired hashtag and search timelines. Use a widget that supports hashtag sources, such as EmbedSocial’s X hashtag feed (Premium plan).

Can I embed an X List on my website?

Yes. Paste the public List URL (https://x.com/i/lists/LIST_ID) into publish.x.com and choose Embedded Timeline. The List timeline shows posts from every account in the List.

Does the X timeline show for visitors who aren't logged in?

Usually, but not always. Developer forum reports show timelines loading blank for some logged-out visitors and during rate limits. A widget that stores the posts itself, like EmbedSocial, doesn’t depend on the visitor’s X session.

Why is my Twitter feed only showing a link to a profile without embedding the widget?

The widgets.js script isn’t loading: your CMS or theme stripped it, a privacy extension blocked platform.x.com, or your single-page app needs twttr.widgets.load() after the embed is added. EmbedSocial avoids this fragile setup with a clean embed snippet that’s easier to control.

Why is my Twitter embed not working?

In most cases your CMS blocks the widgets.js script, an ad blocker interferes, or a Content Security Policy blocks platform.x.com. Allow external scripts from X, or use an optimized embed like EmbedSocial.

How do I embed an X feed on WordPress?

Add a Custom HTML block and paste either the X Publish code or, more reliably, an EmbedSocial widget code. With the X (Twitter) widget for WordPress you also get moderation and a layout that matches your theme.

How to embed live Twitter feeds on Webflow sites?

Create your feed in EmbedSocial, then in Webflow, add an Embed element (HTML block) where you want it to appear and paste the EmbedSocial widget code. Publish the site, and your live Twitter feed will render and keep updating automatically.

How can I embed a Twitter feed on my website via EmbedSocial?

Connect your X (Twitter) account as a source, pick a Twitter widget template, customize the design, then copy the code from the Embed tab and paste it into your site. X accounts need the Pro Plus plan; hashtags, mentions and keywords need Premium.

How to embed an X (Twitter) feed on a website automatically?

Connect your account to EmbedSocial once and it keeps syncing new posts into your widget. You embed the code a single time, and the feed stays fresh without revisiting publish.x.com.

Can you make a Twitter feed for your website using JavaScript?

Yes. The native method uses JavaScript (platform.x.com/widgets.js) to render the timeline, and fully custom builds need the X API. EmbedSocial is the faster route: it handles syncing and rendering and gives you a ready-to-paste widget for any site builder.

Can I embed a private Twitter account?

No. Only public accounts can be embedded. Even managed platforms need public posts to sync content.

How do I make my Twitter feed responsive?

Wrap the embed in a flexible container and avoid fixed widths. For built-in mobile layouts, use a customizable feed like EmbedSocial.

Does embedding Twitter slow down my website?

It can, because it loads an external script and an iframe. Load the script once, keep it async and place the feed below the fold, or use a managed feed that lazy-loads.

Can I customize the Twitter embed colors?

Only a little: the native embed offers a light or dark theme, height and border options. For full design control and brand colors, use a customizable feed like EmbedSocial.

What are Twitter embed links?

The term usually means one of two things: the embed code you get from publish.x.com, or “fix” domains people swap into x.com links so previews show up in chat apps. Those fix domains are third-party services, not official X embeds, and they don’t put a feed on your website.

Nick Poggi, TrovaTrip Ryan Hazlewood Zanna Ollove, Boston College Brooks Hitzfield, Seven Sons
Loved by 400,000+ brands

Put your social proof to work

Aggregate reviews, social media, and UGC. Display them on any website with EmbedSocial widgets.

Start free trial

Cancel anytime. All features included.

Related posts

View all posts