Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pengux/sitemap
Go package to help generating sitemaps
https://github.com/pengux/sitemap
Last synced: about 2 months ago
JSON representation
Go package to help generating sitemaps
- Host: GitHub
- URL: https://github.com/pengux/sitemap
- Owner: pengux
- License: mit
- Created: 2014-04-01T07:14:40.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-04-17T11:06:30.000Z (almost 11 years ago)
- Last Synced: 2024-06-21T03:14:15.838Z (7 months ago)
- Language: Go
- Size: 1.07 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## A Go package to generate sitemaps
Follows the formats and guidelines for [sitemaps.org](http://www.sitemaps.org/). More information at [Google support's answer](https://support.google.com/webmasters/answer/183668)### Installation
```shell
go get github.com/pengux/sitemap
```### Usage
```go
// Import package
import (
...
"github.com/pengux/sitemap"
)// Sitemap item
item := SitemapItem{
"http://www.google.com",
time.Now(),
"hourly",
0.5,
}// Sitemap
sitemap := Sitemap{
[]SitemapItem{
item,
},
}fmt.Print(sitemap.String()) // Output the sitemap as string
sitemap.ToFile("sitemap.xml.gz") // Save sitemap to a gzipped file// SitemapIndexItem
sitemapIndexItem := SitemapIndexItem{
"http://www.google.com/sitemap.xml.gz",
time.Now(),
}// SitemapIndex
sitemapIndex := SitemapIndex{
[]SitemapIndexItem{
sitemapIndexItem,
},
}fmt.Print(sitemapIndex.String()) // Output the sitemap index as string
sitemapIndex.ToFile("sitemap.xml.gz") // Save sitemap to a gzipped file// Create sitemap index from a directory containing sitemap files
sitemapIndex, err := NewIndexFromDir(path, "http://www.google.com/")
```### TODO
- Support sitemap extensions (images, videos, mobile, news)