moonwalker / sitemapgen

Go library for generating sitemaps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sitemapgen

sitemapgen is a Go library to easy generate sitemap.xml files that follows to sitemap protocol

sitemapgen also supports localization urls following the xhtml specification. Read more on google sitemap alternate language

Usage

import (
    "fmt"
    "github.com/moonwalker/sitemapgen"
)
// Create sitemap object to work with
sitemap := sitemapgen.CreateSitemap()

// Create url for an location
u := sitemapgen.CreateUrl("http://example.example/slug")

// Sets the changefreq for the url
u.SetChangeFreq(sitemapgen.WEEKLY)

// Add url to sitemap
sitemap.AddUrl(u)

// Write sitemap to file
err := sitemap.WriteToFile("sitemap.xml")
if err != nil {
    fmt.Printf("Error creating sitemap: %v\n", err)
}

About

Go library for generating sitemaps

License:MIT License


Languages

Language:Go 100.0%