Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/moonwalker/sitemapgen
Go library for generating sitemaps
https://github.com/moonwalker/sitemapgen
Last synced: 8 days ago
JSON representation
Go library for generating sitemaps
- Host: GitHub
- URL: https://github.com/moonwalker/sitemapgen
- Owner: moonwalker
- License: mit
- Created: 2017-09-26T12:53:04.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-10T13:08:19.000Z (about 7 years ago)
- Last Synced: 2024-06-20T12:39:41.317Z (5 months ago)
- Language: Go
- Size: 6.84 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```go
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)
}
```[sitemap protocol]:
[google sitemap alternate language]: https://support.google.com/webmasters/answer/2620865?hl=en