Creates sitemap files
package main
import (
"github.com/pahanini/go-sitemap-generator"
)
g := sitemap.New(sitemap.Options{
Dir: "sitemap",
BaseURL: "http://example.com/",
})
g.Open()
g.Add(sitemap.URL{Loc:`http://example.com`, Priority: `0.5`})
g.Add(sitemap.URL{Loc:`http://example.com/test`, Priority: `0.5`})
g.Close()
If you want to add some images you can use the following
package main
import (
"github.com/pahanini/go-sitemap-generator"
)
g := sitemap.New(sitemap.Options{
Dir: "sitemap",
BaseURL: "http://example.com/",
XMLns: map[string]string{
"xmlns:image": "http://www.google.com/schemas/sitemap-image/1.1",
},
})
images := []sitemap.Image{
sitemap.Image{
Loc: "http://example.com/image",
Title: "Image",
}}
g.Open()
g.Add(sitemap.URL{Loc: `http://example.com`, Priority: `0.5`, Images: images})
g.Close()
$ go get github.com/pahanini/go-sitemap-generator
Sitemap comes with a variety of configuration options. Available Options:
type Options struct {
// Filename is base file name for sitemap w/o extension
// - single file <filename>.xml
// - many files with sitemap index <filename>.xml index and <filename>-<n>.xml files
Filename string
// Max file size (default 10485760)
MaxFileSize int
// Max links in one file (default 50000)
MaxURLs int
// Dir keeps directory name for sitemap files
Dir string
// BaseURL used for generate sitemap index file
BaseURL string
// XML Namespaces
XMLns map[string]string
}