WordPress.org

Ready to get started?Download WordPress

Forums

WordPress SEO by Yoast
Invalid url loc in sitemaps (2 posts)

  1. coati
    Member
    Posted 2 years ago #

    I've noticed some URL's in our sitemap weren't generated correctly.
    Some of them had the site_url missing, which causes errors in Google's Webmaster Tools and probably other parsers too.

    This happens for both post type and images.
    Where a url should have

    <loc>http://domain.com/wpfolder/sub/some-post.html</loc>

    There was

    <loc>/wpfolder/sub/some-post.html</loc>

    I've solved this in the class-sitemaps.php
    At line +-500, replace:

    $output .= "\t\t<loc>".$url['loc']."</loc>\n";

    with

    if ( strpos($url['loc'], 'http') === false )
    	$output .= "\t\t<loc>".home_url($url['loc'])."</loc>\n";
    else
    	$output .= "\t\t<loc>".$url['loc']."</loc>\n";

    The same goes for the image:loc a bit below.

    I'm not sure what causes this, might be with the statement at line 338:

    if ( strpos($src, 'http') !== 0 )

    should be compared to false instead 0 ?

    --coati

    http://wordpress.org/extend/plugins/wordpress-seo/

  2. coati
    Member
    Posted 2 years ago #

    For the images, it looks like there is a check missing in the loop over attachments in a [gallery .. ] block.

    If attachments start with a slash / as path, the siteurl isn't added in front of the image path.
    build_tax_map() also doesn't check this (correctly) because /tag/word url's are going into the taxonomy sitemap without the full url.

    There are several ways to fix this. Imho this should be added somewhere.
    Unless I'm missing something totally..

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic