Jump to content

"Duplicate without user-selected canonical" problem due to require() and include() functions


Recommended Posts

Hi,

I am using a SQL and php code in my website. Every link in my site redirects to the main page with some variable. Such as, for "about me" link is like that :

http://enginery.freecluster.eu/index.php?page=about.html

then, I used "require" function to include the file content of "about.html". My "require()" code is inside index.php(main page of hy site) page. So I put all my external pages into my main page between region "header.php" and "footer.php". So, my index.php file hase these sections :

1) html, head , body tag

2) require(header.php) file (page including main menus of the website) // to use it once and every time 

3) inlcuded external page content is here

4) require(footer.php) file // to use it once and every time

5) closing of body and html tags

 So, when user click to the page link from the main menu, every pages has a content "header.php" and "footer.php". My whole website has similar structure. 

Today I used google search console to apply SEO into my website. However, it gives "Duplicate without user-selected canonical".

I searched the reasons and found that  "The most common trigger is having identical or very similar content that exists on multiple pages of your site." in https://seosly.com/blog/duplicate-without-user-selected-canonical/

So, I am suspecting that, google search engine looks the page, and see that header and footer parts are the same, then it marks all pages as "Duplicate without user-selected canonical" since content is very similar to the index.php page.

I checked one of the errorenous pages and see that, google selected and external page's canonical as "index.php"! So, I can verify that above structure is my problem. 

How can I solve such interwined problems? How can I achieve "click and get" type website content other than this method? Is there any guide or tutorial you know? Thanks.

(my website is http://enginery.freecluster.eu and its site map is in http://enginery.freecluster.eu/sitemap.xml)

 

Edited by eaglehopes
correction of two- three things - not include but require
  • eaglehopes changed the title to "Duplicate without user-selected canonical" problem due to require() and include() functions

Duplicate content warnings are not going to be about the header or footer, provided pages have more content than just that.

The tool should have told you what the duplicates page are. So what are they?

Thanks requinix for answer. But I do not have any duplicate pages. Because there is no duplicate of my "about.html" in any of my website folder(htdocs or subfolders)! So, I have already started coding to solve it by using setting each external page's canonicals into index.php by using this function :

<?php
// use this code in index.php or in another page
$page = isset($_GET['page']) ? $_GET['page'] : 'default';

// create URL
$canonicalUrl = 'https://www.example.com/' . $page . '.php';
?>
<link rel="canonical" href="<?php echo $canonicalUrl; ?>" /> <!-- write canonical, both can be inside php code or outside of it, it does not matter-->

So, I think this will add each page's canonical when sended into index.php, then it will stop giving this error. I also started to code changing the title, keywords and description etc. in  meta tags when a new page sended to "index.php" . 

If this will help solving google search console's errors, I will be post again here and in my web blog as "one of the solutions" of this problem(not error according to google).

46 minutes ago, eaglehopes said:

But I do not have any duplicate pages.

So, what, is the SEO tool hallucinating that you have duplication?

If it says there is duplicate pages then it should also be telling you what pages are the duplicates of each other.

47 minutes ago, eaglehopes said:

So, I think this will add each page's canonical when sended into index.php, then it will stop giving this error.

What you're doing is claiming that the canonical URL for a page is like /about.php. As far as I can see, URLs like that do not work. So this is going to create problems.

:D Google search console(GSC) tool does not say anything about which page is duplicate of the other explicity, but you can learn it by inspecting the problematic page. I did this inspection and saw that it says :

"http://enginery.freecluster.eu/index.php?page=about" page is duplicate of "http://enginery.freecluster.eu/index.php" 

and GSC tool select the "http://enginery.freecluster.eu/index.php"  as "http://enginery.freecluster.eu/index.php?page=about"'s canonical. I am thinking that, GSC look a resemblence ratio for its test. When a two page's content resemblence is higher than predefined ratio, then it sticks immediately "duplicate" mark. 

Also my about.html page content is so little regarding the rest of the page (i.e. header+footer) then, it could not pass the "duplicate test".

So, I am externally give each page's canonical to GSC, which is the same in my sitemap, to overcome this issue.

What is your code for this site? It's not behaving correctly, and I suspect you're using session variables for something that shouldn't be using session variables.
What I see is that the first visit to your site redirects me to /?i=1 and the home page, then I click About and go to /index.php?page=about, then when I try to go to / (or /index.php) I continue getting the about page. That happens for the last page I visit, whichever page that is.

That is what the SEO tools has detected.

  • Great Answer 1
15 hours ago, requinix said:

What is your code for this site? It's not behaving correctly, and I suspect you're using session variables for something that shouldn't be using session variables.
What I see is that the first visit to your site redirects me to /?i=1 and the home page, then I click About and go to /index.php?page=about, then when I try to go to / (or /index.php) I continue getting the about page. That happens for the last page I visit, whichever page that is.

That is what the SEO tools has detected.

OMG ! You are right! I am looking my code for solution... I am looking for unnecessary SESSION variables... 

Ok, I think I solved my BIG problem of using unnecessary SESSION variables instead of GET ! I checked my site again and again...   Thanks requinix !! It saved me a lot of troubles, both current one and future ones! 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.