Globes

Resolving Duplicate Pages and Indexibilty issues by Fixing Canonical Tags

The Issue

We identified a critical issue on the /portal/ pages where the canonical tag appeared correctly in the source code within the <head> section but ended up being rendered in the <body> section of the HTML. This discrepancy caused conflicting signals to Google, leading the search engine to ignore the canonical tag altogether.

Source code

GSC URL Inspection

URL Inspection Tool

How We Found the Issue

During the investigation, we discovered that blocking a specific JavaScript file prevented the canonical tag from moving to the <body> section. The problematic file was:

https://www.globes.co.il/static/cache/js/header.js?ver=1@4b24

When this file was disabled, the canonical tag remained correctly positioned in the <head> section.

Further analysis suggested that the issue might be related to a function within the script called collector_feeder. This function uses the document.write() method to inject an iframe element into the DOM:

document.write(‘<iframe name=…’);

This action appeared to push certain blocks, including the canonical tag, down into the <body> section.

Resolution Steps

To address the issue, we followed a structured process:

Identifying the Problematic Script:

We blocked the JavaScript file https://www.globes.co.il/static/cache/js/header.js?ver=1@4b24 and confirmed that the canonical tag no longer moved to the <body> section.

We reviewed the script to understand its impact on the DOM structure.

Analyzing the JavaScript Code:

The collector_feeder function was found to be dynamically injecting iframes using document.write(). This method can manipulate the DOM post-load, causing unexpected behavior in the placement of elements.

Fixing the Canonical Tag Placement:

We modified the problematic script to ensure that critical meta tags, including the canonical tag, remained in the <head> section.

We also implemented additional checks to prevent future manipulations of critical tags by third-party scripts.

Results

After fixing the canonical tag placement issue, we observed a significant improvement in organic performance:

Increase in Organic Clicks:

Organic clicks to the /portal/ pages increased

Improved Indexing:

The issue with duplicate pages was resolved, leading to more efficient crawling and improved indexing by Google.

Key Takeaways

Always ensure that critical meta tags, especially canonical tags, remain in the <head> section.

Use browser developer tools to inspect the rendered HTML and identify potential DOM manipulations caused by JavaScript.

Regularly audit third-party scripts and CMS plugins to prevent unexpected changes to the page structure.

By addressing the canonical tag issue on the /portal/ pages, we demonstrated how small technical fixes can lead to substantial improvements in organic search performance.

Excellent choice 💪

I am interested in?

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed quis rhoncus libero. Vivamus interdum fringilla erat.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed quis rhoncus libero. Vivamus interdum fringilla erat.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed quis rhoncus libero. Vivamus interdum fringilla erat.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed quis rhoncus libero. Vivamus interdum fringilla erat.