Missing trailing slash in Home link
-
In this code for the <head> section generated by the wordpress-seo plug-in, the blog url is missing the trailing slash.
<script type=’application/ld+json’>{“@context”:”http:\/\/schema.org”,”@type”:”Organization”,“url”:”https:\/\/www.domainnamehere.com\/blog”,”sameAs”:[],”name”:”Company Name Here”,”logo”:”https:\/\/www.domainnamehere.com\/blog\/wp-content\/uploads\/2015\/04\/logo2.png”}</script>
I’ve done other corrections by editing the breadcrumbs function add_home_crumb() by changing get_home_url() to trailingslashit( get_home_url() ). I also had the same problem on the home page of my blog with the link rel=”canonical” and meta property=”og:url” both missing the trailing slash. I solved this by adding the following lines to functions.php in my theme directory:
//* Add fix for trailing slash on home page
function wpseo_canonical_home_url_fix( $canonical_url ) {
// Simply add a trailing slash if it hasn’t one
return trailingslashit( $canonical_url );
}
add_filter( ‘wpseo_canonical’, ‘wpseo_canonical_home_url_fix’ );But I can’t seem to correct the problem for the <head> code mentioned above. I would also prefer to use just the root domain instead of the URL to the blog for this.
- The topic ‘Missing trailing slash in Home link’ is closed to new replies.