GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Search::Sitemap(3) User Contributed Perl Documentation Search::Sitemap(3)

Search::Sitemap - Perl extension for managing Search Engine Sitemaps

  use Search::Sitemap;
  
  my $map = Search::Sitemap->new();
  $map->read( 'sitemap.gz' );
  
  # Main page, changes a lot because of the blog
  $map->add( Search::Sitemap::URL->new(
    loc        => 'http://www.jasonkohles.com/',
    lastmod    => '2005-06-03',
    changefreq => 'daily',
    priority   => 1.0,
  ) );
  
  # Top level directories, don't change as much, and have a lower priority
  $map->add( {
    loc        => "http://www.jasonkohles.com/$_/",
    changefreq => 'weekly',
    priority   => 0.9, # lower priority than the home page
  } ) for qw(
    software gpg hamradio photos scuba snippets tools
  );
  
  $map->write( 'sitemap.gz' );

The Sitemap Protocol allows you to inform search engine crawlers about URLs on your Web sites that are available for crawling. A Sitemap consists of a list of URLs and may also contain additional information about those URLs, such as when they were last modified, how frequently they change, etc.

This module allows you to create and modify sitemaps.

Creates a new Search::Sitemap object.

  my $map = Search::Sitemap->new();

Read a sitemap in to this object. Reading of compressed files is done automatically if the filename ends with .gz.

Write the sitemap out to a file. Writing of compressed files is done automatically if the filename ends with .gz.

Return the Search::Sitemap::URLStore object that make up the sitemap.

To get all urls (Search::Sitemap::URL objects) please use:

    my @urls = $map->urls->all;

Add the Search::Sitemap::URL items listed to the sitemap.

If you pass hashrefs instead of objects, it will turn them into objects for you. If the first item you pass is a simple scalar that matches \w, it will assume that the values passed are a hash for a single object. If the first item passed matches m{^\w+://} (i.e. it looks like a URL) then all the arguments will be treated as URLs, and Search::Sitemap::URL objects will be constructed for them, but only the loc field will be populated.

This means you can do any of these:

  # create the Search::Sitemap::URL object yourself
  my $url = Search::Sitemap::URL->new(
    loc => 'http://www.jasonkohles.com/',
    priority => 1.0,
  );
  $map->add($url);
  
  # or
  $map->add(
    { loc => 'http://www.jasonkohles.com/' },
    { loc => 'http://www.jasonkohles.com/software/search-sitemap/' },
    { loc => 'http://www.jasonkohles.com/software/geo-shapefile/' },
  );
  
  # or
  $map->add(
    loc       => 'http://www.jasonkohles.com/',
    priority  => 1.0,
  );
  
  # or even something funkier
  $map->add( qw(
    http://www.jasonkohles.com/
    http://www.jasonkohles.com/software/search-sitemap/
    http://www.jasonkohles.com/software/geo-shapefile/
    http://www.jasonkohles.com/software/text-fakedata/
  ) );
  foreach my $url ( $map->urls ) { $url->changefreq( 'daily' ) }

Similar to "add", but while "add" will replace an existing object that has the same URL, update will update the provided values.

As as example, if you do this:

    $map->add(
        loc         => 'http://www.example.com/',
        priority    => 1.0,
    );
    $map->add(
        loc         => 'http://www.example.com/',
        changefreq  => 'daily',
    );

The sitemap will end up containing this:

    <url>
        <loc>http://www.example.com</loc>
        <changefreq>daily</changefreq>
    </url>

But if instead you use update:

    $map->update(
        loc         => 'http://www.example.com/',
        priority    => 1.0,
    );
    $map->update(
        loc         => 'http://www.example.com/',
        changefreq  => 'daily',
    );

This sitemap will end up with this:

    <url>
        <loc>http://www.example.com</loc>
        <changefreq>daily</changefreq>
        <priority>1.0</priority>
    </url>

Return the xml representation of the sitemap.

Set this to a true value to enable 'pretty-printing' on the XML output. If false (the default) the XML will be more compact but not as easily readable for humans (Google and other computers won't care what you set this to).

If you set this to a 'word' (something that matches /[a-z]/i), then that value will be passed to XML::Twig directly (see the XML::Twig pretty_print documentation). Otherwise if a true value is passed, it means 'nice', and a false value means 'none'.

Returns the value it was set to, or the current value if called with no arguments.

The home page of this module is <http://www.jasonkohles.com/software/search-sitemap>. This is where you can always find the latest version, development versions, and bug reports. You will also find a link there to report bugs.

Thanks to Alex J. G. Burzyński for help with maintaining this module.

Search::Sitemap::Index

Search::Sitemap::Ping

Search::Sitemap::Robot

<http://www.jasonkohles.com/software/search-sitemap>

<http://www.sitemaps.org/>

Jason Kohles, <email@jasonkohles.com>

Copyright (C) 2005-2009 by Jason Kohles

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

2011-05-27 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.