If a taxonomy term page has an alias generated by pathauto or the like (i.e. alias exists in `url_alias` table), this alias may not be included in the xml sitemap; instead, the original url (taxonomy/term/%tid) may be used.

I've changed the code to use drupal_get_path_alias() to check for a path alias before committing the path to the object that will eventually be written to the database (and eventually to the sitemap file). This is safe, since drupal_get_path_alias() returns "An aliased path if one was found, or the original path if no alias was found."

A patch is attached. First drupal patch, hope it is in the right format.

I am not sure if this should just be added, or if you want to have a UI option for the user to select this (since, there have not been a zillion complaints about this)

CommentFileSizeAuthor
xmlsitemap_taxonomy_path-alias.patch604 bytesMike_Waters

Comments

dave reid’s picture

Status: Active » Needs work

This is really unnessary. We run all the database paths through url() during generation in 6.x-1.x which automatically looks up url aliases.

function _xmlsitemap_create_cache_chunk($fp, $chunk_size, $chunk = 0) {
  $links = db_query_range("SELECT xsm.loc, xsm.module, xsm.type, xsm.id, xsm.sid, xsm.changed, xsm.changefreq, xsm.priority". xmlsitemap_sitemap_query() ."ORDER BY xsm.priority DESC, xsm.changed DESC, xsm.changefreq, xsm.loc", $start, $chunk_size);
  while ($link = db_fetch_object($links)) {
    if ($link->type == 'frontpage') {
      $url = url(NULL, array('absolute' => TRUE));
    }
    else {
      $url = url($link->loc, array('absolute' => TRUE));
    }

So you need to debug this and figure out why url() isn't getting the url alias during generation.

Mike_Waters’s picture

This was only a problem for taxonomy terms that existed before the xmlsitemap module was installed (I believe that Iforgot to mention this. Now I rememeber why I didn't submit it yesterday).
This patch, in my case, fixed the problem completely.

Anonymous’s picture

I keep asking myself "Isn't this resolved by Global Redirect"? Note that Global Redirect module weight is set very high and xmlsitemap's modules' weights needs to be after Global Redirect.

dave reid’s picture

Status: Needs work » Postponed (maintainer needs more info)

Global redirect doesn't act on url() though. I still don't see why this is needed or why its good since it's now storying aliased paths in the sitemap data when it should be un-aliased paths. As I pointed out, all the data should be running through url() during generation.

avpaderno’s picture

Storing the aliased paths in the sitemap data is clearly not the solution, as Dave already pointed out.

I also don't see what the problem is with having not aliased paths in the sitemap. If the problem is that Google reports pages with duplicated meta tags, or title, then the problem is resolved by adding the canonical URL meta tags to the pages (which is not in the scope of XML sitemap).
As far, XML sitemap always use url() for generating the URLs; if there is a problem with finding the path alias, then that is a problem of Drupal core code, and XML sitemap cannot do anything for that.

dave reid’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

At this point, this issue is going to be marked as won't fix. This is either not in the direction of the project, or too out of the project scope.

This message is automatically generated. If you feel it could be improved, feel free to comment on http://drupal.org/node/467548

ilanhaz’s picture

In Drupal 6, I encountered a problem: The taxonomy URL paths on the sitemap page are not in the URL paths’ alias format.
I searched the web for solutions but non have been worked for me.
I had to change one line in the module code in order for it to work.
See Drupal Sitemap does not show URL aliases