Documentation ¶
Index ¶
- type ChangeFreq
- type Options
- type Sitemap
- func (s *Sitemap) Add(u *SitemapLoc) error
- func (s *Sitemap) Finalize()
- func (s *Sitemap) GetURLsCount() int
- func (s *Sitemap) Save() (filenames []string, err error)
- func (s *Sitemap) SetCompress(compress bool)
- func (s *Sitemap) SetHostname(hostname string)
- func (s *Sitemap) SetLastMod(lastMod *time.Time)
- func (s *Sitemap) SetName(name string)
- func (s *Sitemap) SetOutputPath(outputPath string)
- func (s *Sitemap) WriteTo(w io.Writer) (n int64, err error)
- type SitemapIndex
- func (s *SitemapIndex) Add(u *SitemapIndexLoc)
- func (s *SitemapIndex) AppendSitemap(sm *Sitemap)
- func (s *SitemapIndex) NewSitemap() *Sitemap
- func (s *SitemapIndex) PingSearchEngines(pingURLs ...string) error
- func (s *SitemapIndex) Save() (string, error)
- func (s *SitemapIndex) SetCompress(compress bool)
- func (s *SitemapIndex) SetHostname(hostname string)
- func (s *SitemapIndex) SetOutputPath(outputPath string)
- func (s *SitemapIndex) SetServerURI(serverURI string)
- func (s *SitemapIndex) SetSitemapIndexName(name string)
- func (s *SitemapIndex) WriteTo(writer io.Writer) (int64, error)
- type SitemapIndexLoc
- type SitemapLoc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChangeFreq ¶
type ChangeFreq string
ChangeFreq is used for defining changefreq property in sitemap url items.
const ( Always ChangeFreq = "always" Hourly ChangeFreq = "hourly" Daily ChangeFreq = "daily" Weekly ChangeFreq = "weekly" Monthly ChangeFreq = "monthly" Yearly ChangeFreq = "yearly" Never ChangeFreq = "never" )
predefined ChangeFreq frequency values
type Options ¶
type Options struct { Compress bool `xml:"-"` Name string `xml:"-"` Hostname string `xml:"-"` OutputPath string `xml:"-"` // contains filtered or unexported fields }
Options contains general attributes of Sitemap and SitemapIndex. OutputPath is the dir path to save the SitemapIndex file and it's sitemaps. Name of Sitemap output xml file which must be without ".xml" extension. Hostname of Sitemap urls which be prepended to all URLs. Compress option can be either enabled or disabled for Sitemap and SitemapIndex.
type Sitemap ¶
type Sitemap struct { Options SitemapIndexLoc *SitemapIndexLoc NextSitemap *Sitemap // contains filtered or unexported fields }
Sitemap struct which contains Options for general attributes, SitemapLoc as its location in SitemapIndex, NextSitemap that is a Linked-List pointing to the next Sitemap for large files.
func NewSitemap ¶
NewSitemap builds and returns a new Sitemap.
func (*Sitemap) Add ¶
func (s *Sitemap) Add(u *SitemapLoc) error
Add adds an URL to a Sitemap. in case of exceeding the Sitemaps.org limits, splits the Sitemap into several Sitemap instances using a Linked List
func (*Sitemap) Finalize ¶
func (s *Sitemap) Finalize()
Finalize closes the XML data set and do not allow any further sm.Add() calls
func (*Sitemap) GetURLsCount ¶
GetURLsCount returns the number of added URL items into this single sitemap.
func (*Sitemap) Save ¶
Save makes the OutputPath in case of absence and saves the Sitemap into OutputPath using it's Name. it returns the filename.
func (*Sitemap) SetCompress ¶
SetCompress sets the Compress option to be either enabled or disabled for Sitemap When Compress is enabled, the output file is compressed using gzip with .xml.gz extension.
func (*Sitemap) SetHostname ¶
SetHostname sets the Hostname of Sitemap urls which be prepended to all URLs. Note: you do not have to call SetHostname in case you are building Sitemap using SitemapIndex.NewSitemap but you can set a separate Hostname for a specific Sitemap using SetHostname, else the SitemapIndex.SetHostname does this action for all Sitemaps of the entire SitemapIndex.
func (*Sitemap) SetLastMod ¶
SetLastMod sets the LastMod if this Sitemap which will be used in it's URL in SitemapIndex
func (*Sitemap) SetName ¶
SetName sets the Name of Sitemap output xml file It must be without ".xml" extension
func (*Sitemap) SetOutputPath ¶
SetOutputPath sets the OutputPath of Sitemap which will be used to save the xml file. Note: you do not have to call SetOutputPath in case you are building Sitemap using SitemapIndex.NewSitemap but you can set a separate OutputPath for a specific Sitemap using SetOutputPath, else the SitemapIndex.SetOutputPath does this action for all Sitemaps of the entire SitemapIndex.
type SitemapIndex ¶
type SitemapIndex struct { Options XMLName xml.Name `xml:"sitemapindex"` Xmlns string `xml:"xmlns,attr"` SitemapLocs []*SitemapIndexLoc `xml:"sitemap"` Sitemaps []*Sitemap `xml:"-"` ServerURI string `xml:"-"` // contains filtered or unexported fields }
SitemapIndex contains sitemap_index items which are SitemapURLs. New instances must be created with NewSitemapIndex() in order to set the Xmlns attribute correctly. Options is for general attributes Name is the filename which is used in Save method. Hostname is a prefix which wll be used for all URLs in SitemapIndex and it's Sitemaps. SitemapLocs is list of location structs of its Sitemaps. Sitemaps contains all Sitemaps which is belong to this SitemapIndex. ServerURI is used for making url of Sitemap in SitemapIndex.
func NewSitemapIndex ¶
func NewSitemapIndex(prettyPrint bool) *SitemapIndex
NewSitemapIndex builds returns new SitemapIndex. prettyPrint param makes the file easy to read and is recommended to be set to false for production use and is not changeable after initialization.
func (*SitemapIndex) Add ¶
func (s *SitemapIndex) Add(u *SitemapIndexLoc)
Add adds an URL to a SitemapIndex.
func (*SitemapIndex) AppendSitemap ¶
func (s *SitemapIndex) AppendSitemap(sm *Sitemap)
AppendSitemap appends a Sitemap instance into it's Sitemaps. Does not change and configurations.
func (*SitemapIndex) NewSitemap ¶
func (s *SitemapIndex) NewSitemap() *Sitemap
NewSitemap builds a new instance of Sitemap and appends it in SitemapIndex's Sitemaps and sets it's Name nad Hostname
func (*SitemapIndex) PingSearchEngines ¶
func (s *SitemapIndex) PingSearchEngines(pingURLs ...string) error
PingSearchEngines pings search engines
func (*SitemapIndex) Save ¶
func (s *SitemapIndex) Save() (string, error)
Save makes the OutputPath in case of absence and saves the SitemapIndex and it's Sitemaps into OutputPath as separate files using their Name.
func (*SitemapIndex) SetCompress ¶
func (s *SitemapIndex) SetCompress(compress bool)
SetCompress sets the Compress option to be either enabled or disabled for SitemapIndex and it's Sitemaps and sets it as Compress of new Sitemap entries built using NewSitemap method. When Compress is enabled, the output file is compressed using gzip with .xml.gz extension.
func (*SitemapIndex) SetHostname ¶
func (s *SitemapIndex) SetHostname(hostname string)
SetHostname sets the Hostname for SitemapIndex and it's Sitemaps and sets it as Hostname of new Sitemap entries built using NewSitemap method.
func (*SitemapIndex) SetOutputPath ¶
func (s *SitemapIndex) SetOutputPath(outputPath string)
SetOutputPath sets the OutputPath for SitemapIndex and it's Sitemaps and sets it as OutputPath of new Sitemap entries built using NewSitemap method. this path can be a multi-level dir path and will be used in Save method.
func (*SitemapIndex) SetServerURI ¶
func (s *SitemapIndex) SetServerURI(serverURI string)
SetServerURI sets the ServerURI for SitemapIndex and it's Sitemaps and sets it as OutputPath of new Sitemap entries built using NewSitemap method.
func (*SitemapIndex) SetSitemapIndexName ¶
func (s *SitemapIndex) SetSitemapIndexName(name string)
SetSitemapIndexName sets the filename of SitemapIndex which be used to save the xml file. name param must not have .xml extension.
type SitemapIndexLoc ¶
type SitemapIndexLoc struct { XMLName xml.Name `xml:"sitemap"` Loc string `xml:"loc"` LastMod *time.Time `xml:"lastmod,omitempty"` }
SitemapIndexLoc contains data related to <sitemap> tag in SitemapIndex.
type SitemapLoc ¶
type SitemapLoc struct { XMLName xml.Name `xml:"url"` Loc string `xml:"loc"` LastMod *time.Time `xml:"lastmod,omitempty"` ChangeFreq ChangeFreq `xml:"changefreq,omitempty"` Priority float32 `xml:"priority,omitempty"` }
SitemapLoc contains data related to <url> tag in Sitemap.