sitemap

package module
v0.0.0-...-7cb2691 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2015 License: MIT Imports: 2 Imported by: 0

README

sitemap

Build Status xrefs funcs top func library users status

Package sitemap generates sitemap.xml files based on the sitemaps.org protocol.

Documentation and usage examples at sourcegraph.com/github.com/sourcegraph/sitemap

Documentation

Overview

Package sitemap generates sitemap.xml files based on the sitemaps.org protocol.

Index

Constants

View Source
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
)
View Source
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

View Source
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")
)
View Source
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

func Marshal(urlset *URLSet) (sitemapXML []byte, err error)

Marshal serializes the sitemap URLSet to XML, with the <urlset> xmlns added and the XML preamble prepended.

func MarshalIndex

func MarshalIndex(index *Index) (indexXML []byte, err error)

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

type Sitemap struct {
	Loc     string `xml:"loc"`
	LastMod string `xml:"lastmod,omitempty"`
}

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.

type URLSet

type URLSet struct {
	XMLName xml.Name `xml:"urlset"`
	XMLNS   string   `xml:"xmlns,attr"`
	URLs    []URL    `xml:"url"`
}

URLSet represents a set of URLs in a sitemap.

Refer to http://www.sitemaps.org/protocol.html#xmlTagDefinitions for more information.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL