How to Add a Google Translate Button to Your Website

Walid Hasan1 min read
How to Add a Google Translate Button to Your Website

Your website visitors could be from all around the world, and this means language read is spoken natively. It’s a fast and free change you can make to make your site more accessible, user-friendly, and internationally optimized.

In this tutorial, we’ll be teaching you how to implement Google Translate in your website with just a few lines of HTML and JavaScript. Let’s get started!

What Is Google Translate?

Google Translate is a free multilingual machine translation service developed by Google. It offers the ability for users to instantly translate text, web pages, and documents to and from more than 100 languages. It’s available as:

  • A website interface
  • Android & iOS mobile apps
  • A JS API for devs and site owners

Webpage: Step-by-Step

Step 1: Get Google Translate Widget Code

Paste this in Settings → Advanced → Code Injection → Header:

<!-- Google Translate Widget -->
<div id="google_translate_element"></div>
<!-- Google Translate Script -->
<script type="text/javascript">
  function googleTranslateElementInit() {
    new google.translate.TranslateElement({
      pageLanguage: 'en',
      includedLanguages: 'en,bn,hi,ar,fr,es', // Customize this list
      layout: google.translate.TranslateElement.InlineLayout.SIMPLE,
      autoDisplay: false
    }, 'google_translate_element');
  }
</script>
<script src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
  • This will load Google Translate and initialize the widget at the top of your site.

Step 2: Style the Translate Dropdown

(Optional but recommended for better design)

Paste this in Pages → Custom Code → Custom CSS

#google_translate_element {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 9999;
  background: #fff;
  padding: 5px 10px;
  border-radius: 6px;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
  font-size: 14px;
}
.goog-te-gadget img {
  display: none; /* Hide Google branding flag icon */
}

This CSS:

  • Positions the widget at the top-right corner
  • Styles it neatly
  • Hides unnecessary icons for a clean look

Final Thoughts

A Google Translate button is a quick and easy way to reach a global audience with your website. This makes content accessible to non-native English speakers and people with disabilities, without the use of costly plugins or translation services.


Frequently Asked Questions

1. Can I use Google Translate for free on my site?

Yes! The widget is offered to you at no cost. And you don’t even need to pay for an API or subscribe: You can embed it on your website with Google’s official script.

2. Is it possible to style the Translate Dropdown?

Absolutely. You are able to style the widget with CSS like in the example above—place the widget where you want it to be displayed, style the background, text, text position, and font, and even hide the Google flag icon.

3. Where do I place the Google Translate code in my website?

Copy the HTML and JavaScript into

Settings → Advanced → Code Injection → Header in most website builders like Squarespace.

Directly in the <head> section of your HTML file if you're coding manually.

4. Is the translate button going to make my website slow?

No, Google Translate is fast and is not a blocking call. It will have little to no impact on your website’s speed or performance.

5. Can I set my site’s default language?

Yes. Simply replace the value for pageLanguage: 'en' in the source with the language string for your site's original language (i.e., 'fr' for French, 'es' for Spanish).

Walid Hasan
Author Bio

Walid Hasan

I'm Walid Hasan, a Certified Squarespace Expert and Squarespace Circle Platinum Partner with over 12 years of hands-on experience designing and optimizing high-performing websites. Over the years, I've had the privilege of building more than 2,000 Squarespace websites for clients around the world, always focusing on clean design, strong user experience, and conversion-driven results.

More Tutorials

See If Squareko Is Right For You.

Schedule a call with us to discuss your project in detail and receive a tailored solution. Let's turn your vision into reality - book your FREE consultation today!

Let’s Talk About Your Project
  • Squareko completely transformed our online presence. The new website is modern, fast, and easy to use… our site looks amazing and performs even better! ⭐⭐⭐⭐⭐
  • 𝗬𝗼𝘂𝗿 𝗽𝗵𝗼𝘁𝗼𝘀 𝗮𝗿𝗲 𝘀𝘁𝘂𝗻𝗻𝗶𝗻𝗴. 𝗬𝗼𝘂𝗿 𝘄𝗲𝗯𝘀𝗶𝘁𝗲? 𝗣𝗿𝗼𝗯𝗮𝗯𝗹𝘆 𝗻𝗼𝘁. 📷
  • 𝗥𝗲𝘀𝘁𝗮𝘂𝗿𝗮𝗻𝘁 𝗼𝘄𝗻𝗲𝗿𝘀 𝘆𝗼𝘂𝗿 𝘄𝗲𝗯𝘀𝗶𝘁𝗲 𝗶𝘀 𝘁𝗵𝗲 𝗳𝗶𝗿𝘀𝘁 𝘁𝗵𝗶𝗻𝗴 𝗮 𝗻𝗲𝘄 𝗰𝘂𝘀𝘁𝗼𝗺𝗲𝗿 𝘀𝗲𝗲𝘀 𝗯𝗲𝗳𝗼𝗿𝗲 𝘁𝗵𝗲𝘆 𝗲𝘃𝗲𝗿 𝘄𝗮𝗹𝗸 𝘁𝗵𝗿𝗼𝘂𝗴𝗵 𝘆𝗼𝘂𝗿 𝗱𝗼𝗼𝗿.
  • 𝗧𝗵𝗶𝘀 𝗶𝘀 𝘄𝗵𝗮𝘁 𝗮 𝗳𝗶𝘁𝗻𝗲𝘀𝘀 𝘄𝗲𝗯𝘀𝗶𝘁𝗲 𝘀𝗵𝗼𝘂𝗹𝗱 𝗮𝗰𝘁𝘂𝗮𝗹𝗹𝘆 𝗹𝗼𝗼𝗸 𝗹𝗶𝗸𝗲. 💪
  • 𝗦𝗾𝘂𝗮𝗿𝗲𝘀𝗽𝗮𝗰𝗲 𝗷𝘂𝘀𝘁 𝗿𝗲𝗳𝗿𝗲𝘀𝗵𝗲𝗱 𝘁𝗵𝗲 𝗖𝗶𝗿𝗰𝗹𝗲 𝗟𝗮𝗯𝘀 𝗽𝗮𝗻𝗲𝗹 — 𝗮𝗻𝗱 𝗶𝘁'𝘀 𝗮 𝗴𝗲𝗻𝘂𝗶𝗻𝗲𝗹𝘆 𝘂𝘀𝗲𝗳𝘂𝗹 𝘂𝗽𝗴𝗿𝗮𝗱𝗲.
  • 𝗔 𝘄𝗲𝗹𝗹-𝗱𝗲𝘀𝗶𝗴𝗻𝗲𝗱 𝘄𝗲𝗯𝘀𝗶𝘁𝗲 𝗵𝗲𝗹𝗽𝘀 𝗯𝘂𝘀𝗶𝗻𝗲𝘀𝘀𝗲𝘀 𝗰𝗼𝗺𝗺𝘂𝗻𝗶𝗰𝗮𝘁𝗲 𝘁𝗵𝗲𝗶𝗿 𝘃𝗮𝗹𝘂𝗲 𝗶𝗻𝘀𝘁𝗮𝗻𝘁𝗹𝘆.