A flexible library for creating sitemap and google video sitemaps in Go
go get -u github.com/sosolyht/go-sitemap/sitemap
Here is an example of how to use the Go Sitemap Generator library to create both standard and video sitemaps.
package main
import "github.com/sosolyht/go-sitemap/sitemap"
func main() {
// Create a sitemap with path
s := sitemap.NewSitemap().Path("util/sitemaps")
links := []string{
"https://google.com",
"https://naver.com",
}
for _, link := range links {
s.AddURL(link)
}
// Create a video sitemap
vs := sitemap.NewVideoSitemap()
videoURLs := []sitemap.VideoURL{
// ... (the example video URLs)
}
for _, videoURL := range videoURLs {
vs.AddVideoURL(videoURL)
}
}
Replace the videoURLs variable with your video URLs and their respective video information.
The sitemaps will be generated and saved as sitemaps/sitemap.xml
and sitemaps/sitemap_video.xml
respectively.