Change footer language

SOLVE
lait
Participant

Hello,

 

I have a template page in English and French (landing_page.html and landing_page_fr.html + footer.html and footer_fr.html). I would like to add a logic to my base.html file (see last lines of code below) to change the footer, according to the page's language (i.e. if I am on the French page I should have footer_fr and vice versa).

 

Any help would be appreciated. Thank you

 

<!--
  templateType: none
-->
<!doctype html>
<html lang="{{ html_lang }}" {{ html_lang_dir }}>
  <head>
    <meta charset="utf-8">
    {% if page_meta.html_title %}<title>{{ page_meta.html_title }}</title>{% endif %}
    {% if site_settings.favicon_src %}<link rel="shortcut icon" href="{{ site_settings.favicon_src }}" />{% endif %}
    <meta name="description" content="{{ page_meta.meta_description }}">
    {{ require_css(get_asset_url("../../css/main.css")) }}
    {# This is intended to be used if a template requires template specific style sheets #}
    {% if template_css %}
      {{ require_css(get_asset_url(template_css)) }}
    {% endif %}
    {{ require_js(get_asset_url('../../js/read-more.js')) }}
    {{ require_js(get_asset_url('../../js/mobile-signup-button.js')) }}
    {{ require_js(get_asset_url('../../js/submit-form.js')) }}
    {# JS for field format masks #}
    {{ require_js('https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.15/jquery.mask.min.js') }}
    {{require_js('https://cdnjs.cloudflare.com/ajax/libs/libphonenumber-js/1.9.19/libphonenumber-js.min.js', 'head')}}
    {{ require_js(get_asset_url('../../js/fields_masks.js')) }}
    {#{ require_js(get_asset_url('../../js/fields_validators.js')) }#}
    {# To see a full list of what is included via standard_header_includes please reference this article: https://developers.hubspot.com/docs/cms/hubl/variables#required-page-template-variables #}
    {{ standard_header_includes }}
  </head>
  <body>
    <div class="body-wrapper {{ builtin_body_classes }}">
      {% block header %}
        {#% include '../partials/header.html' %#}
      {% endblock header %}

      {% block body %}
      {% endblock body %}

      {% block footer %}
      
      {#This is not working, not sure what variable I should use#}
      {% if 'landing_page.html' %}
       {% include '../partials/footer.html' %}
          {% elif 'landing_page_fr.html' %}
       {% include '../partials/footer_fr.html' %}
          {% endif %}
      
      {% endblock footer %}
    </div>
    {# To see a full list of what is included via standard_footer_includes please reference this article: https://developers.hubspot.com/docs/cms/hubl/variables#required-page-template-variables #}
    {{ standard_footer_includes }}
  </body>
</html>
0 Upvotes
1 Accepted solution

Accepted Solutions
piersg
Solution
Key Advisor

You could do

{% if content.language.languageTag  == 'fr' %}
  {% include '../partials/footer_fr.html' %}
{% else %}
  {% include '../partials/footer.html' %}
{% endif %}

 

Although it would be easier to be have one footer module that is a global module. Global modules can be translated and the logic for displaying the correct translation is done for you:

piersg_0-1625818932582.png

 

View solution in original post

0 Upvotes
2 Replies 2
piersg
Solution
Key Advisor

You could do

{% if content.language.languageTag  == 'fr' %}
  {% include '../partials/footer_fr.html' %}
{% else %}
  {% include '../partials/footer.html' %}
{% endif %}

 

Although it would be easier to be have one footer module that is a global module. Global modules can be translated and the logic for displaying the correct translation is done for you:

piersg_0-1625818932582.png

 

View solution in original post

0 Upvotes
webdew
Top Contributor | Diamond Partner

Hi @lait ,

You can change the footer and header navigation according to a different language. Please refer to these documents. https://knowledge.hubspot.com/website-pages/create-pages-in-multiple-languages


Hope this helps!


If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards. 

0 Upvotes