<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to Hide Language Variations from Different Countries on Your HubSpot Landing Pages in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/How-to-Hide-Language-Variations-from-Different-Countries-on-Your/m-p/1132670#M42630</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074"&gt;@Jaycee_Lewis&lt;/a&gt;, that would be great! I am sure plenty of customers would find this helpful! Thank you!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 06 Apr 2025 19:16:19 GMT</pubDate>
    <dc:creator>Franci</dc:creator>
    <dc:date>2025-04-06T19:16:19Z</dc:date>
    <item>
      <title>How to Hide Language Variations from Different Countries on Your HubSpot Landing Pages</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-Hide-Language-Variations-from-Different-Countries-on-Your/m-p/1129627#M42565</link>
      <description>&lt;H3 class="" data-start="1110" data-end="1140"&gt;&lt;STRONG data-start="1114" data-end="1140"&gt;Why is This Important?&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P class="" data-start="116" data-end="363"&gt;As a global marketer, providing an excellent user experience across regions is crucial. HubSpot’s default language-country switcher allows visitors to choose their preferred language and region, but it can show irrelevant options, confusing users.&lt;/P&gt;
&lt;P class="" data-start="116" data-end="363"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="" data-start="365" data-end="611"&gt;In countries like Switzerland and Luxembourg, where multiple official languages exist, visitors might see options they don’t need. For example, a Swiss visitor could see French, German, Italian, or even English options — all valid in Switzerland.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3 class="" data-start="1110" data-end="1140"&gt;&lt;STRONG data-start="1114" data-end="1140"&gt;The Problem: Confusing Language Options&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P class="" data-start="658" data-end="757"&gt;By default, HubSpot allows users to switch between all available language-country options, such as:&lt;/P&gt;
&lt;UL data-start="2113" data-end="2216"&gt;
&lt;LI class="" data-start="2113" data-end="2150"&gt;
&lt;P class="" data-start="2115" data-end="2150"&gt;&lt;CODE data-start="2115" data-end="2124"&gt;/en-us/&lt;/CODE&gt; (English - United States)&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="" data-start="2151" data-end="2185"&gt;
&lt;P class="" data-start="2153" data-end="2185"&gt;&lt;CODE data-start="2153" data-end="2162"&gt;/fr-ch/&lt;/CODE&gt; (French - Switzerland)&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="" data-start="2186" data-end="2216"&gt;
&lt;P class="" data-start="2188" data-end="2216"&gt;&lt;CODE data-start="2188" data-end="2197"&gt;/de-at/&lt;/CODE&gt; (German - Austria)&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P class="" data-start="847" data-end="927"&gt;This can be confusing for users if they see options irrelevant to their country.&lt;/P&gt;
&lt;P class="" data-start="2218" data-end="2465"&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3 class="" data-start="2467" data-end="2534"&gt;&lt;STRONG data-start="2471" data-end="2534"&gt;The Solution: A Dynamic, Country-Specific Language Switcher&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P class="" data-start="2536" data-end="2747"&gt;With a &lt;STRONG data-start="2548" data-end="2577"&gt;little bit of custom code&lt;/STRONG&gt;, we can make the language switcher more intelligent by ensuring that only &lt;STRONG data-start="2652" data-end="2715"&gt;the language-country options relevant to the user’s country&lt;/STRONG&gt; (based on the URL) are visible.&lt;/P&gt;
&lt;P class="" data-start="2749" data-end="2795"&gt;Let’s walk through how you can implement this.&lt;/P&gt;
&lt;HR data-start="2797" data-end="2800" /&gt;
&lt;H3 class="" data-start="2802" data-end="2848"&gt;&lt;STRONG data-start="2806" data-end="2848"&gt;The Code: A Simple, Universal Solution&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P class="" data-start="2850" data-end="2962"&gt;Here’s the script that will dynamically hide language-country variations that don’t match the visitor’s country:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;&amp;lt;script&amp;gt;
document.addEventListener("DOMContentLoaded", function () {
// Extract language-country from the URL path (e.g., "it-it" from "/it-it/")
const pathSegments = window.location.pathname.split("/");
const currentLangCountry = pathSegments[1]; // Example: "it-it"

if (!currentLangCountry || !currentLangCountry.includes("-")) {
  return;
}

const currentCountry = currentLangCountry.split("-")[1].toLowerCase(); // Extract "it" from "it-it"

// Find the language switcher menu
const languageSwitcher = document.querySelector(".languageswitcher");

if (!languageSwitcher) {
  return;
}

// Get all language options
const options = languageSwitcher.querySelectorAll(".hs-language-switcher__item a");

options.forEach(option =&amp;gt; {
  const href = option.getAttribute("href");

  // Extract language-country from href (supports both relative and absolute URLs)
  const langCountryMatch = href.match(/\/([a-z]{2}-[a-z]{2})\//i);

  if (langCountryMatch) {
    const langCountry = langCountryMatch[1]; // Example: "fr-ch"
    const optionCountry = langCountry.split("-")[1].toLowerCase(); // Extract "ch" from "fr-ch"

    if (optionCountry !== currentCountry) {
      option.style.display = "none"; // Hide unwanted options
    }
  }
});
});
&amp;lt;/script&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3 class="" data-start="4786" data-end="4820"&gt;&lt;STRONG data-start="4790" data-end="4820"&gt;How Does This Script Work?&lt;/STRONG&gt;&lt;/H3&gt;
&lt;OL data-start="4822" data-end="5428"&gt;
&lt;LI class="" data-start="4822" data-end="4989"&gt;
&lt;P class="" data-start="4825" data-end="4989"&gt;&lt;STRONG data-start="4825" data-end="4858"&gt;Extracts Country from the URL&lt;/STRONG&gt;: The script checks the current page URL (e.g., &lt;CODE data-start="4906" data-end="4915"&gt;/fr-ch/&lt;/CODE&gt; or &lt;CODE data-start="4919" data-end="4928"&gt;/en-us/&lt;/CODE&gt;) and extracts the country code (e.g., &lt;CODE data-start="4967" data-end="4971"&gt;ch&lt;/CODE&gt; for Switzerland).&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="" data-start="4994" data-end="5244"&gt;
&lt;P class="" data-start="4997" data-end="5244"&gt;&lt;STRONG data-start="4997" data-end="5029"&gt;Filters the Language Options&lt;/STRONG&gt;: It looks for the language switcher (&lt;CODE data-start="5067" data-end="5086"&gt;.languageswitcher&lt;/CODE&gt;) and checks each available language option. If the country code in the option’s link doesn’t match the country extracted from the URL, that option is hidden.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="" data-start="5246" data-end="5428"&gt;
&lt;P class="" data-start="5249" data-end="5428"&gt;&lt;STRONG data-start="5249" data-end="5288"&gt;Works for Any Country-Language Pair&lt;/STRONG&gt;: Whether you’re dealing with &lt;CODE data-start="5318" data-end="5325"&gt;en-us&lt;/CODE&gt;, &lt;CODE data-start="5327" data-end="5334"&gt;fr-ch&lt;/CODE&gt;, &lt;CODE data-start="5336" data-end="5343"&gt;de-at&lt;/CODE&gt;, or any other language-country pair, the script adapts and hides irrelevant options.&lt;/P&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;H3 class="" data-start="5435" data-end="5464"&gt;&amp;nbsp;&lt;/H3&gt;
&lt;H3 class="" data-start="5435" data-end="5464"&gt;&lt;STRONG data-start="5439" data-end="5464"&gt;Why This Is So Useful&lt;/STRONG&gt;&lt;/H3&gt;
&lt;UL data-start="5466" data-end="6199"&gt;
&lt;LI class="" data-start="5466" data-end="5648"&gt;
&lt;P class="" data-start="5468" data-end="5648"&gt;&lt;STRONG data-start="5468" data-end="5499"&gt;Tailored for Local Visitors&lt;/STRONG&gt;: The script ensures that your landing pages are more personalized by showing only the relevant language options for the country the visitor is from.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="" data-start="5649" data-end="5812"&gt;
&lt;P class="" data-start="5651" data-end="5812"&gt;&lt;STRONG data-start="5651" data-end="5679"&gt;Improves User Experience&lt;/STRONG&gt;: By hiding unnecessary options, you reduce user confusion, making it easier for visitors to navigate and find the content they need.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="" data-start="5813" data-end="6024"&gt;
&lt;P class="" data-start="5815" data-end="6024"&gt;&lt;STRONG data-start="5815" data-end="5851"&gt;Works for Multilingual Countries&lt;/STRONG&gt;: For countries with multiple official languages like Switzerland and Luxembourg, all language variations will still be shown when they are relevant to the visitor’s region.&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3 class="" data-start="6206" data-end="6265"&gt;&lt;STRONG data-start="6210" data-end="6265"&gt;How to Add This Script to Your HubSpot Landing Page&lt;/STRONG&gt;&lt;/H3&gt;
&lt;OL data-start="6267" data-end="6737"&gt;
&lt;LI class="" data-start="6267" data-end="6380"&gt;
&lt;P class="" data-start="6270" data-end="6380"&gt;&lt;STRONG data-start="6270" data-end="6296"&gt;Open Your Landing Page&lt;/STRONG&gt;: In HubSpot, navigate to the landing page where you want to implement this feature.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="" data-start="6385" data-end="6521"&gt;
&lt;P class="" data-start="6388" data-end="6521"&gt;&lt;STRONG data-start="6388" data-end="6416"&gt;Go to the Settings -&amp;gt; Advanced&lt;/STRONG&gt;: Add the above script to the &lt;STRONG data-start="6446" data-end="6456"&gt;Footer HTML&lt;/STRONG&gt; section.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="" data-start="6526" data-end="6737"&gt;
&lt;P class="" data-start="6529" data-end="6737"&gt;&lt;STRONG data-start="6529" data-end="6540"&gt;Test It&lt;/STRONG&gt;: After you’ve added the script, visit your page and change the URL to reflect different language-country pairs. You should only see the language options that correspond to your country in the URL.&lt;/P&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;HR data-start="6739" data-end="6742" /&gt;
&lt;H3 class="" data-start="6744" data-end="6766"&gt;&lt;STRONG data-start="6748" data-end="6766"&gt;Final Thoughts&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P class="" data-start="6768" data-end="7096"&gt;This simple script is a game-changer for creating a more intuitive, localized experience on your HubSpot landing pages. By hiding language variations from different countries, you ensure that your international visitors only see the content relevant to their region, making the entire experience more seamless and user-friendly.&lt;/P&gt;
&lt;P class="" data-start="7098" data-end="7281"&gt;If you found this helpful, feel free to share it with your fellow marketers in the HubSpot community! And if you have any questions, don’t hesitate to reach out. Happy optimizing! &lt;span class="lia-unicode-emoji" title=":globe_showing_europe_africa:"&gt;🌍&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":sparkles:"&gt;✨&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Mar 2025 09:30:00 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-Hide-Language-Variations-from-Different-Countries-on-Your/m-p/1129627#M42565</guid>
      <dc:creator>Franci</dc:creator>
      <dc:date>2025-03-31T09:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to Hide Language Variations from Different Countries on Your HubSpot Landing Pages</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-Hide-Language-Variations-from-Different-Countries-on-Your/m-p/1129632#M42566</link>
      <description>&lt;P&gt;Great! I've been looking forward to a solution for ages...Great job, thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 31 Mar 2025 09:12:48 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-Hide-Language-Variations-from-Different-Countries-on-Your/m-p/1129632#M42566</guid>
      <dc:creator>aimar17</dc:creator>
      <dc:date>2025-03-31T09:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to Hide Language Variations from Different Countries on Your HubSpot Landing Pages</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-Hide-Language-Variations-from-Different-Countries-on-Your/m-p/1129635#M42567</link>
      <description>&lt;P&gt;This is truly a game-changer! Thanks for sharing this solution with the community!&lt;/P&gt;</description>
      <pubDate>Mon, 31 Mar 2025 09:25:08 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-Hide-Language-Variations-from-Different-Countries-on-Your/m-p/1129635#M42567</guid>
      <dc:creator>Alessio_M</dc:creator>
      <dc:date>2025-03-31T09:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to Hide Language Variations from Different Countries on Your HubSpot Landing Pages</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-Hide-Language-Variations-from-Different-Countries-on-Your/m-p/1129869#M42573</link>
      <description>&lt;P&gt;Great solution!&lt;/P&gt;</description>
      <pubDate>Mon, 31 Mar 2025 18:44:37 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-Hide-Language-Variations-from-Different-Countries-on-Your/m-p/1129869#M42573</guid>
      <dc:creator>PAngioi</dc:creator>
      <dc:date>2025-03-31T18:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to Hide Language Variations from Different Countries on Your HubSpot Landing Pages</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-Hide-Language-Variations-from-Different-Countries-on-Your/m-p/1132174#M42627</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/484534"&gt;@Franci&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt; This is great! I can't accept your OP as a solution, but if you'll come back and leave a comment, I can mark that one as a solution so you get even more visibility for your hard work. — Jaycee&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2025 17:19:15 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-Hide-Language-Variations-from-Different-Countries-on-Your/m-p/1132174#M42627</guid>
      <dc:creator>Jaycee_Lewis</dc:creator>
      <dc:date>2025-04-04T17:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to Hide Language Variations from Different Countries on Your HubSpot Landing Pages</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-Hide-Language-Variations-from-Different-Countries-on-Your/m-p/1132670#M42630</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074"&gt;@Jaycee_Lewis&lt;/a&gt;, that would be great! I am sure plenty of customers would find this helpful! Thank you!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Apr 2025 19:16:19 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-Hide-Language-Variations-from-Different-Countries-on-Your/m-p/1132670#M42630</guid>
      <dc:creator>Franci</dc:creator>
      <dc:date>2025-04-06T19:16:19Z</dc:date>
    </item>
  </channel>
</rss>

