Add a Twitter button to your blog

If your theme does not include a Twitter button and you want to add one, you will need to edit your theme. Contact the designer of your theme if you're not sure if your theme already includes a Twitter button – chances are, there is a theme setting to add Tweet buttons to your blog.

If your theme doesn't have that feature:

  1. From your Shopify admin, click Online Store, and then click Themes (or press G W T).

  2. Find the theme you want to edit, click the ... button, and then click Edit HTML/CSS.

  3. Under the Templates folder, locate and click on article.liquid and blog.liquid to open them in the online code editor.

    Article blog liquid
  4. In blog.liquid and article.liquid — both templates will need to be edited in the same way - look for this code:

    
    {{ article.content }}
    
    

    Above the element that outputs the article content, paste the following code:

    
    <script src="https://platform.twitter.com/widgets.js" type="text/javascript"></script>
    <div>
       <a href="https://twitter.com/share" class="twitter-share-button"
          data-url="{{ shop.url }}{{ article.url }}"
          data-via="your_screen_name"
          data-text="{{ article.title | escape }}"
          data-count="horizontal">Tweet</a>
    </div>
    
    
  5. Replace your_screen_name with your Twitter account alias, without the @. For example, Shopify's twitter account name is shopify.

  6. Save your changes.

Repeat the above procedure for both templates.

Want to discuss this page?

Visit the Shopify Community