Subject: | [PATCH] Don't include empty tags |
I just got around to upgrading from WWW::Google::SiteMap (I had missed
the rename). When I compared my old sitemap to the new one, I found
that Search::Sitemap was including "<priority></priority>" and
"<changefreq></changefreq>" in <url>'s where I had not set a value.
According to sitemaps.org, those tags are optional. I'm not sure how
empty tags would be treated by search engines, but I don't think it's a
good idea to include them.
I've attached the small patch I came up with to fix the problem. It
omits any attribute whose value hasn't been set.
I also fixed what appears to be a typo. The clearer for changefreq was
'clear_lastmod'.
PS: http://www.jasonkohles.com/software/search-sitemap is giving me a
404 error, and http://www.jasonkohles.com/software/ gives me a 403.
PPS: You might want to take WWW-Google-SiteMap-1.09, add a note to the
documentation that it's been replaced by Search-Sitemap, and release it
as WWW-Google-SiteMap-1.10. I bet I'm not the only person who didn't
notice you renamed it.
Subject: | SSU_emptytag.patch |
--- Search/Sitemap/URL.pm 2009-03-28 17:15:08.000000000 -0500
+++ Search/Sitemap/URL.pm 2009-03-28 18:15:39.313792565 -0500
@@ -37,7 +37,7 @@
isa => SitemapChangeFreq,
coerce => 1,
predicate => 'has_changefreq',
- clearer => 'clear_lastmod',
+ clearer => 'clear_changefreq',
);
has 'lastmod' => (
is => 'rw',
@@ -84,6 +84,8 @@
my @elements = ();
for my $f ( @fields ) {
+ my $exists = $self->can("has_$f");
+ next if $exists and not $self->$exists; # Omit missing fields
my $method = '_'.$f.'_as_elt';
my $val;
if ( $self->can( $method ) ) {