3 weeks ago
Hey,
for a subdomain we defined noindex globally in the page settings (header html).
For one single page, we'd like to override these settings and put the meta-tag index in the header instead.
How could we do this?
Solved! Go to Solution.
3 weeks ago - last edited 3 weeks ago
If I'm undestanding you correctly you've added something like:
<meta name="robots" content="noindex">
to your Settings under Website>Pages>Templates>Site header HTML, is that correct?
Rather than adding that there I'd suggest adding something like the below to your themes base.html file (within the <head></head> tags):
{% boolean "no_index" label="Don't Index Page", value=true, no_wrapper=True %}
{% if widget_data.no_index.value == "true" %}
<meta name="robots" content="noindex">
{% endif %}
That way the it should be included by default but you would be able to toggle it off on any page you didn't want it on.
Freelance HubSpot CMS Developer
3 weeks ago - last edited 3 weeks ago
If I'm undestanding you correctly you've added something like:
<meta name="robots" content="noindex">
to your Settings under Website>Pages>Templates>Site header HTML, is that correct?
Rather than adding that there I'd suggest adding something like the below to your themes base.html file (within the <head></head> tags):
{% boolean "no_index" label="Don't Index Page", value=true, no_wrapper=True %}
{% if widget_data.no_index.value == "true" %}
<meta name="robots" content="noindex">
{% endif %}
That way the it should be included by default but you would be able to toggle it off on any page you didn't want it on.
Freelance HubSpot CMS Developer
3 weeks ago
Hi Barry,
thanks for your answer.
My preferred way would be the opposite. It should be no-index by default and only index on single pages.
Could we change your code like this?
{% boolean "index" label="Index this Page", value=true, no_wrapper=True %}
{% if widget_data.index.value == "true" %}
<meta name="robots" content="index">
{% endif %}
3 weeks ago - last edited 3 weeks ago
Hi @beatkoeck,
Sorry, if it wasn't clear but that's exactly what the code I made for you does.
By "toggle if off" I meant toggle the tag off as in remove the tag.
The tag is shown if the box is checked and it's checked by default. So you'd uncheck it on the page you don't want the tag on.
Test it out.
Freelance HubSpot CMS Developer