How to add conditional Hreflangs to webflow cms blog pages?

Hi Everyone

has anyone tried applying hreflangs to cms blog pages only to selected pages ??

I am trying to add hreflangs to the cms blog’s page of my site.
There are three websites for : singapore, hong kong and japan. But not all blogs are related … So I want to add hreflangs only to a few blog pages … How can we do that ?

The webflow rich text field accepts custom code but i have to place it inside the page with in head tags this is creating two head tags and the hreflangs are nolt working properly.

The cms page head tags doesn’t allow a rich text field…

How can i add conditional custom code to head tags of cms blog page ?? or is there any other way around it ??

Google is good at processing custom script, especially if it’s synchronous- so the typical approach here is to write custom code that will generate those.

Another option ( a bit of a hack ) is to e.g. create 6 fields in the CMS, e.g.;

  • Hreflang 1 - option field, with choices alternate or ignore
  • Hreflang Code 1 - text field
  • Hreflang Url 1 - link field
  • Hreflang 2 - option field, with choices alternate or ignore
  • Hreflang Code 2 - text field
  • Hreflang Url 2 - link field
  • Hreflang 3 - option field, with choices alternate or ignore
  • Hreflang Code 4 - text field
  • Hreflang Url 4 - link field

Then drop 3 fields in your CMS page head.

<link rel="{{ Hreflang 1 }}" href="{{ Hreflang Url 1 }}" hreflang="{{ Hreflang Code 1 }}" />
<link rel="{{ Hreflang 2 }}" href="{{ Hreflang Url 2 }}" hreflang="{{ Hreflang Code 2 }}" />
<link rel="{{ Hreflang 3 }}" href="{{ Hreflang Url 3 }}" hreflang="{{ Hreflang Code 3 }}" />

Being able to choose between alternate and ignore for each item determines whether it’s a language alternate or just a meaningless link that searchbots will ignore.

If you populated all 3, and set them all to alternate, you’d get;

<link rel="alternate" href="" hreflang="en-sg" />
<link rel="alternate" href="" hreflang="zh-hk" />
<link rel="alternate" href="" hreflang="ja-jp" />

Or just 1 might look like;

<link rel="alternate" href="" hreflang="en-sg" />
<link rel="ignore" href="" hreflang="" />
<link rel="ignore" href="" hreflang="" />
1 Like

Thanks a lot for the answer…

this could work out… hreflangs are a bit complicated so want to cross check with the SEO team

but thanks a lot for the prompt reply :pray: :pray:

Hi i use webflow for site layout, and use ather cms
You can user wp, getsimple, drupal …

Thanks a lot for the suggestion but … the client wants to prefer to keep everything in webflow right now

Hi @memetican

we implemented it for all 3 site and applied to 100’s of blogs
and it worked well in adding hreflangs to all of them

however for the ignore tags the hreflangs is showing up error

this is how the ignore code looks like and we have added 12 variables for alternate/ignore, site links and language

did you also encounter error for the ignore tags ??

Hi Varun, not sure what you’re saying exactly. You might need examples.
However I generally use script rather than these types of hacks.

You don’t need to worry about errors on irrelevant tags, because they’re irrelevant. It’s just saying “I’m not sure what you’re trying to do here,” and you’re trying to do absolutely nothing, so that’s perfect :wink:

Hi michael

sorry if i was not clear in the explaining the issue.
my client is actually using this toll to check for hreflangs and its showing errors for the ignore tags link to the tool :point_down:t2:

if it doesn’t effect SEO then we would ignore it … but can you please share any scripts you are using other than the code you had previously shared… might as well test that out

It does not affect the SEO.

We write the code for each client individually depending on their site & CMS design and SEO needs, so there is nothing generic to share. However if you’re wanting to take a code approach yourself you should find lots of examples on Google.

okay :+1:t3:

I tried a couple of codes but all of them showed error in the tool. or just weren’t working
your approach was the only thing that worked for the CMS without too many complexity…

anyways will discuss with the SEO team and try to come up with a solution or let it remain as it is.

thanks for all your support …your solution helped me add the hreflangs on the blogs that need them… really appreciate it michael :grin: :pray:t3:

1 Like

Tools like AHREFs do not process pages the way Google does, so the will not execute the script. Google uses a headless chromium instance to evaluate page JS before parsing it.

So in short those tools won’t like it, but that’s not relevant to your SEO. It only matters what Google thinks.

1 Like