[Resolved] Missing Canonicals

Home Forums Support [Resolved] Missing Canonicals

Home Forums Support Missing Canonicals

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #2164169
    troyw

    Hey Team,
    I have just discovered an issue with one of my Generate Press websites, which does not appear to happen on any other websites I have built. When I run Screaming Frog and other tests, it appears that all of my pages are missing Canonicals. I have turned off any plugins I feel could be causing, such as Yoast and WP Rocket, but the issue remains. Obviously this is causing massive issue with how the site is being indexed. Since I think I have eliminated plugins, what is causing this and how can i fix it?

    Thanks

    #2164184
    Fernando
    Customer Support

    Hi Troyw,

    This shouldn’t be a theme related issue. Can you try temporarily using a different theme and see if the same issue exists to confirm?

    Kindly make a backup to make sure you can revert things safely if an issue occurs.

    Can you also try reaching out the support of the plugin you’re using to add the canonical URLs and see if they have an insight with regards to this?

    Hope this helps! 🙂

    #2164186
    troyw

    Hey Fernando. Just tried Twenty Twenty Theme and the issue goes away?
    If I use Generatepress the issue comes back?

    #2164195
    troyw

    I use a Child theme and I have tried removing any introduced code from the functions.php file, but this issue still persists. I also tried removing any other introduced css and php from the Child Sheets and still the issue persists?

    Also, to answer your question about which Plugin I am using to add Canonicals, I am not using one. Yoast has the option, but i have not used it because canonical appears on every page, with or without Yoast activated. <link rel=”canonical” href=”https://www.mywebsite/content/&#8221; />

    #2164203
    Fernando
    Customer Support

    I see.

    There should be no code in GP that should affect this. Can you try using the updated GP parent theme and see if the issue goes away?

    See this for reference: https://generatepress.com/forums/topic/canonical-tag-placed-on-paginated-pages/#post-533029

    Also see: https://generatepress.com/forums/topic/yoast-seo-canonical-tags-not-appearing/#post-1379420

    Kindly let us know how it goes. 🙂

    #2164215
    troyw

    OK. I have put the parent GP Theme on and the issue goes away. When I use the Child Theme, the problem comes back. As mentioned though, I have gone through all 4 files in my Child Theme and removed the content, to see if there is any code causing this.

    The Style.css file has nothing anyway.
    The functions.php has some code, but even when I remove this, clear cache and check again, the issue persists.
    The ctc-style.css is empty
    The header.php has some code, but again, even if I remove this, the issue persists.

    As such, it feels like an issue with the Childtheme and it’s relationship with the Main GP theme, but I cannot see how?

    #2164239
    Fernando
    Customer Support

    I see. Thank you for testing that out.

    With that figured out, can you make an external copy of your custom functions in the Child Theme maybe in a notepad software or somewhere safe, (if you have other files in the child theme, make a copy as well) and then delete the current Child theme you have? Then, reinstall a fresh new copy of the child theme.

    https://generatepress.com/api/themes/generatepress_child.zip

    Test it without your custom functions first, and then put them back one by one and kindly see how it goes.

    Hope this helps! 🙂

    #2164243
    troyw

    Hey Fernando,
    Ill try

    #2164271
    Fernando
    Customer Support

    Alright Troyw! Thank you very much! Kindly let us know how it goes. 🙂

    #2164273
    troyw

    That was a great exercise and it identified the issue. I used your Child Theme File and added my functions.php. All worked well. However, as soon as I added the header.php, the issue returned.
    So I removed the code I had in the Header.php but the issue still persists. I even create a blank header.php and the issue persisted. So for some reason, if I use a header.php file, it causes this issue.

    For now I have removed the Header.php file completely and all is well, however I do have some code in there I would like to use.

    	<?php
    /**
     * The template for displaying the header.
     *
     * @package GeneratePress
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly.
    }
    
    ?><!DOCTYPE html>
    <html <?php language_attributes(); ?>>
    	<meta charset="<?php bloginfo( 'charset' ); ?>">
    	<link rel="profile" href="https://gmpg.org/xfn/11">
    	<?php wp_head(); ?>
    </head>
    	
    <body <?php body_class(); ?> <?php generate_do_microdata( 'body' ); ?>>
    	<?php
    	/**
    	 * wp_body_open hook.
    	 *
    	 * @since 2.3
    	 */
    	do_action( 'wp_body_open' );
    
    	/**
    	 * generate_before_header hook.
    	 *
    	 * @since 0.1
    	 *
    	 * @hooked generate_do_skip_to_content_link - 2
    	 * @hooked generate_top_bar - 5
    	 * @hooked generate_add_navigation_before_header - 5
    	 */
    	do_action( 'generate_before_header' );
    
    	/**
    	 * generate_header hook.
    	 *
    	 * @since 1.3.42
    	 *
    	 * @hooked generate_construct_header - 10
    	 */
    	do_action( 'generate_header' );
    
    	/**
    	 * generate_after_header hook.
    	 *
    	 * @since 0.1
    	 *
    	 * @hooked generate_featured_page_header - 10
    	 */
    	do_action( 'generate_after_header' );
    	?>
    
    	<div id="page" class="hfeed site grid-container container grid-parent">
    		<?php
    		/**
    		 * generate_inside_site_container hook.
    		 *
    		 * @since 2.4
    		 */
    		do_action( 'generate_inside_site_container' );
    		?>
    		<div id="content" class="site-content">
    			<?php
    			/**
    			 * generate_inside_container hook.
    			 *
    			 * @since 0.1
    			 */
    			do_action( 'generate_inside_container' );

    Any idea why I cannot use the header.php in the Childtheme?

    Thanks

    #2164292
    Fernando
    Customer Support

    Great!

    What specific custom code have you added to the header.php? If this code is causing the issue, reaching out to the developer of this custom code might be best.

    Here is the header.php for reference: https://github.com/tomusborne/generatepress/blob/master/header.php

    Kindly check for differences.

    Hope this clarifies. 🙂

    #2164295
    troyw

    No, even if I don’t have any code in the header.php file, the issue occurs. The only way to stop it, is to have no header.php file at all.

    Also, another issue that has manifested, is that some of the Anchor Links in the main navigation, no longer work. This is especially weird because all the other anchor links work in the navigation do work, just not the ones under this Navigation Menu. see below

    #2164307
    Fernando
    Customer Support

    I see. There are some differences in the header.php file you added to your child theme which may be causing the issue. Moreover, having a header.php with no content would cause issues. If you don’t have custom code, then you wouldn’t need to create a header.php file. It already exists through the parent theme.

    With regards to the anchor links, may you kindly create a new topic?

    Hope to hear from you soon. 🙂

    #2164316
    troyw

    Thanks Fernando

    #2164320
    Fernando
    Customer Support

    You’re welcome Troyw! 🙂

Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.