0

I have a D6 site that uses both a geography taxonomy and a category taxonomy to organize 10s of thousands of nodes. XML sitemap does a great job with automatically listing the individual taxonomy pages (all of geography A or all of category B) and the nodes themselves. But I have views set up that show pages for "Category B in Geography A" such as http://example.com/myview/brooklyn/web_designers

I know that you can use xmlsitemap_custom to add these views results one at a time. Is there any way to automate adding the entire cross section of the two taxonomies? I want to add the view for every combination of the two taxonomies to the site map.

0

This is something I have struggled to find an answer for for years - how to get dynamic views to be included in a sitemap and submitted to search engines. I finally found a solution so sharing it here to help others. This is for Drupal 7.

  1. forget xml sitemap. It's great for everything else, but it doesn't do this job well. It's ok to have two sitemaps.
  2. install views datasource and enable at least views xml
  3. create a view that uses xml data document for its format. for settings i have raw xml, root element urlset, top-level child name as url, plaintext output, <?xml-stylesheet type="text/xsl" href="/sitemap.xsl"?> as xml document header, content type default and importantly do NOT check views api mode (or it will output within your theme)
  4. I have some hidden fields for nid and title to build the url and filters for the content type I want to list. I build the links with this php code:

    $newurl = 'http://' . $_SERVER['SERVER_NAME'] . '/res/' . $row->nid . '/' . $row->nid . '/' . str_replace(' ', '-', $row->title);
    if (isset($newurl)) {
      print $newurl;
    }
    

    There are other ways to do this but this was the most efficient way for my case. parse_url may work better for you but for me it was overkill.

  5. updated date can be gotten from the content and the other sitemap fields you can just use custom text fields for.

  6. in .htaccess, right below where RewriteBase is (whether it's commented out or not), add in a permanent redirect from the content type to the view. Will look something like this: RewriteCond %{REQUEST_URI} CONTENT_TYPE_PATH/([0-9]+)/(.) RewriteRule ^CONTENT_TYPE_PATH/([0-9]+)/(.)$ http://%{HTTP_HOST}/VIEW_PATH/$1/$2? [L,R=301] NOTE: with MAMP local install and some shared hosting this doesn't work. You can google for some suggested workarounds - none worked for me for MAMP but I decided I didn't need to worry about this for my local install and it works on my host.
  7. make sure xml sitemap module excludes content type, rebuild if needed
  8. add templates for sitemap view, use theme suggestions for specific name. I needed to add html, page and views overrides to make sure it only outputs the xml data
  9. add http://www.google.com/ping?sitemap=http://MYSITE/MYSITEMAPVIEW etc to custom submission urls in xml sitemap config. Optionally also add to robots.txt and/or submit manually - i did all 3 :) I think that's about it, but if I missed a step let me know and i'll fill in the missing parts.
1

Drupal 6

Option 1:

  1. Enable the 6.x-2.x XML sitemap custom sub-module.
  2. Manually add the links to your views at admin/settings/xmlsitemap/custom

Option 2:

  1. Enable the 6.x-2.x XML sitemap menu sub-module.
  2. Create a new menu at admin/build/menu/add with the menu name xmlsitemap and title XML sitemap. Make sure that the 'Include this menu in the sitemap.' checkbox is selected.
  3. Edit your view's page view, and add the view to the 'XML sitemap' menu under the 'Page settings'.

Drupal 7

  1. Modules/XML Sitemap: Check "XML sitemap node" (Adds content links to the sitemap.)
  2. Configuration/Search and Metadata/XML sitemap/Settings: Click on the "Content" tab. Go to your View created content, click on it.
  3. In the XML sitemap tab, set Inclusion to Included. Save.
  4. Back to Configuration/Search and Metadata/XML sitemap/ - click on Rebuild Links. You'll now have all of the Views created pages listed in sitemap.xml
0

You can implement hook_xmlsitemap_link_info(), and insert your links programmatically.

See api for datails.

  • thanks I'll check that out... probably need a new custom module to accomplish this, right? – squarecandy Apr 9 '13 at 22:34
  • yep, as an example you can use xmlsitemap_taxonomy module – Oleg Sherbakov Apr 9 '13 at 22:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.