Prevent indexing of headings with conditional visibility

Hi there,

I am encountering an SEO issue on my site and I imagine that it is a problem that has already been encountered.

On a CMS resource page, I use conditional visibility for entire sections. For example, the visible sections will not be the same if the resource is of type “Article”, “Guide”, “Webinar”, etc.

Here is the problem :
In terms of SEO, even sections that are not supposed to appear are spotted by bots when crawling pages.

I tried with a script like this:

<script>
$(".w-condition-invisible").remove();
</script>

In the DOM, I actually have the sections in question which no longer appear. On the other hand, the SEO crawl always brings up several H1 or H2 which should not be there.

Is there a solution offered by Webflow or a hack allowing you to have clean CMS pages in terms of SEO when there is conditional visibility?

Thank you for your help,
Have a good day,
Aurélie

That’s a tough one. You may get better results if you avoid using jQuery, since that will only run after the jQuery lib has loaded at the end of the page.

Instead you could put a piece of code in your before-/BODY the runs synchronously, something like this.

Google will likely have a better change of executing this before it indexes the page, other search engines, not so much.

Your only other option on a Webflow-hosted site is a reverse proxy to remove those elements so that they’re gone before browsers and search engines see them.

<script>
var elements = document.querySelectorAll('.w-condition-invisible');
elements.forEach(function(element) {
   element.parentNode.removeChild(element);
});
</script>