Documentation ¶
Overview ¶
Package sitemap generates sitemap.xml files based on the sitemaps.org protocol.
Index ¶
Constants ¶
const ( // MaxURLs is the maximum allowable number of URLs in a sitemap <urlset>, // per http://www.sitemaps.org/protocol.html#index. MaxURLs = 50000 // MaxFileSize is the maximum allowable uncompressed size of a sitemap.xml // file, per http://www.sitemaps.org/protocol.html#index. MaxFileSize = 10 * 1024 * 1024 )
const MaxSitemaps = 50000
MaxSitemaps is the maximum allowable number of sitemap entries in a sitemap index, per http://www.sitemaps.org/protocol.html#index.
Variables ¶
var ( // ErrExceededMaxURLs is an error indicating that the sitemap has more // than the allowable MaxURLs URL entries. ErrExceededMaxURLs = errors.New("exceeded maximum number of URLs in a sitemap <urlset>") // ErrExceededMaxFileSize is an error indicating that the sitemap or sitemap // index file size exceeds the allowable MaxFileSize byte size. ErrExceededMaxFileSize = errors.New("exceeded maximum file size of a sitemap or sitemap index XML file") )
var ErrExceededMaxSitemaps = errors.New("exceeded maximum number of sitemaps in a sitemap index")
ErrExceededMaxSitemaps is an error indicating that the sitemap index has more than the allowable MaxSitemaps sitemap entries.
Functions ¶
func Marshal ¶
Marshal serializes the sitemap URLSet to XML, with the <urlset> xmlns added and the XML preamble prepended.
func MarshalIndex ¶
MarshalIndex serializes the sitemap index to XML, with the <sitemapindex> xmlns added and the XML preamble prepended.
Types ¶
type ChangeFreq ¶
type ChangeFreq string
ChangeFreq indicates how frequently the page is likely to change. This value provides general information to search engines and may not correlate exactly to how often they crawl the page.
Refer to http://www.sitemaps.org/protocol.html#xmlTagDefinitions for more information.
const ( Always ChangeFreq = "always" Hourly ChangeFreq = "hourly" Daily ChangeFreq = "daily" Weekly ChangeFreq = "weekly" Monthly ChangeFreq = "monthly" Yearly ChangeFreq = "yearly" Never ChangeFreq = "never" )
type Index ¶
type Index struct { XMLName xml.Name `xml:"sitemapindex"` XMLNS string `xml:"xmlns,attr"` Sitemaps []Sitemap `xml:"sitemap"` }
Index represents a collection of sitemaps in a sitemap index.
Refer to http://www.sitemaps.org/protocol.html#index for more information.
type Sitemap ¶
Sitemap represents information about an individual sitemap in a sitemap index.
Refer to http://www.sitemaps.org/protocol.html#index for more information.
type URL ¶
type URL struct { Loc string `xml:"loc"` LastMod string `xml:"lastmod,omitempty"` ChangeFreq ChangeFreq `xml:"changefreq,omitempty"` Priority float64 `xml:"priority,omitempty"` }
URL presents a URL and associated sitemap information.
Refer to http://www.sitemaps.org/protocol.html#xmlTagDefinitions for more information.