Skip to content

Latest commit

 

History

History
52 lines (42 loc) · 978 Bytes

README.md

File metadata and controls

52 lines (42 loc) · 978 Bytes

sitemap

Is a package that generate XML sitemap from the given page objects.

It implement the sitemap page and sitemap index.

Documentation can be found at: http://godoc.org/github.com/alexandreStein/sitemap

Example:

package main

import (
	"fmt"
	"time"

	"github.com/alexandreStein/sitemap"
)

func main() {
	// Set the last modification to now
	now := time.Now()

	// Initialize a standard sitemap
	sMap := sitemap.Page{
		Urlset: []*sitemap.Sitemap{
			&sitemap.Sitemap{
				Loc:        "https://www.test.com",
				LastMod:    &now,
				Changefreq: sitemap.Daily,
				Priority:   0.5,
			},
		},
	}
	// Build the XML output
	x, err := sMap.GetXML()
	fmt.Println(string(x), err)

	// Initialize an index sitemap
	sMapi := sitemap.IndexPage{
		Urlset: []*sitemap.Sitemap{
			&sitemap.Sitemap{
				Loc: "https://www.test.com/sitemap.xml",
			},
		},
	}
	// Same as sitemap page build the XML using GetXML
	x, err = sMapi.GetXML()
	fmt.Println(string(x), err)
}