Canonical Tag for Archive and category pages
-
Hi,
We are using Yoast SEO version 3.9, How can we add canonical tag for archive and category page. I read about the article on your site but I can’t find it on the Yoast SEO plugin we are using. Hope you can help us. Thanks
-
Hi,
Do you have enabled advanced settings?
https://kb.yoast.com/kb/remove-advanced-yoast-seo-settings/Do you enable meta box for categories/tags?
SEO > Titlte & Metas > Taxonomies
Choice Show for “Yoast SEO Meta Box”.If you see meta box, but it doesn’t work, send screenshot with more details.
I forgot to write:
WP Dashboard -> Posts -> Categories -> find category item and click on Edit
Bellow Name, Slug, Description, you should see Yoast SEO metabox, select settings (last of 3 buttons) and you will see Canonical URL. (if you want some customization)
Yoast generates “Canonical URL” for all pages on fly.Please check the attach images. Thanks
https://www.screencast.com/t/uOfOPj0lHe
https://www.screencast.com/t/bjbCConuv11These settings are OK. When you open WP dashboard and open Categories (in Posts menu for example), you need to find specific category and press Edit. You should see editor with title, description, …. Bellow this you will see Yoast SEO Meta Box. There you can put custom canonical URL. You can choice preferred URL if you have multiple categories in an URL. (you can’t change existent URLs, you can select better variant for canonical).
I hope that I explained it better than first time.
For example I have a category “test” and I put the https://site.com/category/test in Yoast SEO Meta Box. But when I view the page source in the browser, the canonical tag was not showing.
OK. I think that I understand better now.
By default Yoast SEO adds canonical tags on the fly and you don’t need any settings for it. If you don’t see
<link rel="canonical" href="...
in HTML source, it could be conflict between plugins and it’s something strange.
Do you have some custom code? Can you send more details about theme, plugins?Can you try https://kb.yoast.com/kb/how-to-check-for-plugin-conflicts/ ?
I’m using Dynamic Child theme for Genesis Theme.
Here’s list of plugins
Broken Link Checker
Contact Form 7
DashNex Plugin
Genesis Simple Edits
Genesis Simple Sidebars
Google XML Sitemaps
HTML Page Sitemap
iThemes Security
Limit Login Attempts
Official StatCounter Plugin
Page Builder by SiteOrigin
Project Supremacy Plugin
Quick Page/Post Redirect Plugin
SERPed.net
Simple video sitemap generator
SiteOrigin Widgets Bundle
WP Image App
WP Super Cache
Yoast SEOHere’s custom code
add_filter( 'genesis_seo_title', 'dc_seo_title', 10, 1 ); function dc_seo_title( $title ) { $title = '<p itemprop="headline" class="site-title"><a title="' . get_bloginfo('name') . '" href="' . get_bloginfo('url') . '">' . get_bloginfo('name') . '</a></p>'; return $title; } add_filter( 'genesis_seo_description', 'dc_seo_description' ); function dc_seo_description($description) { $description = '<p class="site-description" itemprop="description">' . get_bloginfo('description') . '</p>'; return $description; } add_action( 'genesis_entry_header', 'dc_new_content_sidebar_wrap', 15 ); function dc_new_content_sidebar_wrap() { echo '<div class="new-content-sidebar-wrap">'; } add_action( 'genesis_entry_header', 'dc_new_content_wrap', 15); function dc_new_content_wrap () { if ( is_single() ) { echo '<div class="new-content-wrap" itemprop="articleBody">'; } else { echo '<div class="new-content-wrap" itemprop="mainContentOfPage">'; } } add_action( 'genesis_entry_content', 'page_spacer', 5 ); function page_spacer () { if ( is_page() ) { echo '<p class="spacer"> </p>'; } } remove_action( 'genesis_entry_header', 'genesis_post_info', 12); add_action( 'genesis_entry_content', 'genesis_post_info', 5 ); remove_action( 'genesis_after_entry', 'genesis_get_comments_template' ); add_action( 'genesis_entry_footer', 'genesis_get_comments_template', 15 ); add_action( 'genesis_entry_footer', 'dc_new_content_wrap_close', 16 ); function dc_new_content_wrap_close() { echo '</div><!-- close new wrap -->'; } remove_action( 'genesis_after_content', 'genesis_get_sidebar' ); add_action( 'genesis_entry_footer', 'genesis_get_sidebar', 17 ); add_action( 'genesis_entry_footer', 'dc_new_content_sidebar_wrap_close', 18 ); function dc_new_content_sidebar_wrap_close() { echo '</div><!-- close new sidebar wrap -->'; } /* Remove comment form allowed tags */ add_filter( 'comment_form_defaults', 'dc_remove_comment_allowed_tags' ); function dc_remove_comment_allowed_tags( $defaults ) { $defaults['comment_notes_after'] = ''; return $defaults; } /* Remove comments from attachments */ function filter_media_comment_status( $open, $post_id ) { $post = get_post( $post_id ); if( $post->post_type == 'attachment' ) { return false; } return $open; } add_filter( 'comments_open', 'filter_media_comment_status', 10 , 2 ); /* multi purpose empty array for selectively deleting schema */ function custom_schema_empty( $attributes ){ $attributes['itemtype'] = ''; $attributes['itemprop'] = ''; $attributes['itemscope'] = ''; return $attributes; } add_filter( 'genesis_attr_content', 'custom_schema_empty', 20 ); /* removes mainContentOfPage */ add_filter( 'genesis_attr_entry-content', 'custom_schema_empty'); /* Schema Changes */ add_filter( 'genesis_attr_entry', 'custom_genesis_attr_entry' ); function custom_genesis_attr_entry ($attributes) { if ( is_single() ) { $attributes['itemtype'] = 'https://schema.org/BlogPosting'; } else { $attributes['itemtype'] = ''; $attributes['itemprop'] = ''; $attributes['itemscope'] = ''; } return $attributes; } add_filter( 'genesis_attr_body', 'custom_post_attr_body' ); function custom_post_attr_body ($attributes) { if ( is_single() ) { $attributes['itemtype'] = 'https://schema.org/Blog'; } else { $attributes['itemtype'] = 'https://schema.org/WebPage'; } return $attributes; }
Thanks
-
This reply was modified 8 years, 3 months ago by
Steven Stern (sterndata).
-
This reply was modified 8 years, 3 months ago by
Steven Stern (sterndata). Reason: put code in backticks
@dranreb I see a plugin ( Google XML Sitemaps ) which can be in conflict and you should see notifications in Yoast. Maybe this plugin isn’t active.
Please follow instructions from https://kb.yoast.com/kb/how-to-check-for-plugin-conflicts/, deactivate plugin by plugin and check tags at each deactivation. Try to switch theme to WP default ( eg. twentysixteen ) and check tags.
-
This reply was modified 8 years, 3 months ago by
- The topic ‘Canonical Tag for Archive and category pages’ is closed to new replies.