How do I add icons w/ links on the blog listing page

Hi, hope someone can help me.
What is the best way to add icons with links to other versions of the blog.
What kind of code snippet should I use and where is the best place to put it?

Here is a illuratration of how I’m trying to get it to look like with flag icons:

and this is the code snippet on the top of the listingpage:
<div class=“bloglist-container”>
{% if topic %}
<div class=“topic-title”>
<h1>
You’re now reading more about: {{ topic|replace(‘-’,’ ')|title }}
</h1>
</div>
{% endif %}

Kind regards
Pernille

Can you explain more about what you mean by “other versions of the blog”? Are you saying you have a separate blog for French, English, Spanish and you want to add links to the top of the page for those?

Thank you for your comment.

Yes, I have created Norwegian and Swedish versions that I would like to link up to the blog. (found in another post that this was the best solution for having the blog in different languages)

So, english blog links to NO and SWE and Norwegian to SWE and ENG and Swedish to NO and ENG. Using flag icons with links.

@Stephanie-OG - You live in ths space more than I do, do you happen to have an html snippet or custom module for flags?

I have nothing pre-built, although I’m in the process of translating my site (I haven’t reached the blog yet), so maybe soon!

I think there are different ways of doing it and it depends on how you have the blog set up. Asumming your blogs are called ENG, SWE and NOR, for example, these should appear in the URL (www.website.com/ENG, www.website.com/ENG/post-name… etc.) so you could do something like this:

{% if 'ENG' in content.absolute_url %}
 {# Code that displays SWE and NOR flags #}
{% elif 'SWE' in content.absolute_url %}
 {# Code that displays ENG and NOR flags #}
{% elif 'NOR' in content.absolute_url %}
 {# Code that displays SWE and ENG flags #}
{% endif %}

I’m wondering if it’s more efficient to have a loop where you can just have all three flags and exclude the one that matches the URL using “display: none”. Something like:

{% set languages = ['ENG', 'SWE', 'NOR'] %}

<div class="flags">
 <!-- ENG flag-->
 <a class="ENG" href="#"><img src="/link-to-ENG-flag"></a>
 <!-- SWE flag-->
 <a class="SWE" href="#"><img src="/link-to-SWE-flag"></a>
 <!-- NOR flag-->
 <a class="NOR" href="#"><img src="/link-to-NOR-flag"></a>
</div>

<style>
{% for language in languages %}
 {% if language in content.absolute_url %}
 .{{ language }} { display: none; }
 {% endif %}
{% endfor %}
</style>

(I haven’t tested this so tweaking is probably needed).


|300HubSpot Design / Development / Automation

Website | Contact

Hi,

Thank you for the code snippet Stephanie, it seems to nearly work.

The flags are showing in the preview:

I’m having problems getting them visable on a live page it’s induvidual who can see the flags, I’m thinking mabye it’s because of screen size as a colleauge could see the flags straight over the top left box.

The code looks like this now:

I will try to test further to see how I can get it to appear on every type of screen. If anyone see anything that could be done differently regarding the placing of the code, please shout out :slightly_smiling_face:

I’m glad to see it (almost) works! Perhaps some styling of the “flags” class is needed? Do you have a link to the preview that we can take a look at?


|300HubSpot Design / Development / Automation

Website | Contact

Of course, here’s a link: https://app.hubspot.com/design-previewer/2211763/templates/4428570413
Thank you for engaging :slightly_smiling_face: This community is great!

No problem! That link requires that we log in to your portal, but when you click on preview you should have a “Preview without display options” as well that can be shared publicly.


|300HubSpot Design / Development / Automation

Website | Contact

If this helped, please mark it as the solution to your question, thanks!

Thank you for making me aware of this function. I’m new to sharing outside org. I’m so sorry for this!

Here’s a new link: https://preview.hs-sites.com/_hcms/preview/template/multi?blog_listing=true&content_group_id=null&is_buffered_template_layout=true&portalId=2211763&tc_deviceCategory=undefined&template_layout_id=4428570413&updated=1534511050907

Here you go, I wasn’t aware of this function:
https://preview.hs-sites.com/_hcms/preview/template/multi?blog_listing=true&content_group_id=null&is_buffered_template_layout=true&portalId=2211763&tc_deviceCategory=undefined&template_layout_id=4428570413&updated=1534511050907

I can see it when I open the preview on my screen.

The only reason I can see that one wouldn’t appear is if the name of the language appears in the URL (ENG, SWE or NOR). They’re set to appear by default otherwise.

Also, I believe that code is for the Blog Listings template, have you added it to the Blog Post template as well? (Or you can create a custom module and add it outside of the two).


|300HubSpot Design / Development / Automation

Website | Contact

If this helped, please mark it as the solution to your question, thanks!

Also, I just found this handy blog post on how to add a multi-language switcher that you might find interesting.


|300HubSpot Design / Development / Automation

Website | Contact

If this helped, please mark it as the solution to your question, thanks!