go-sitemap-generator alternatives and similar packages
Based on the "Utilities" category.
Alternatively, view go-sitemap-generator alternatives based on common mentions on social networks and blogs.
-
项目文档
基于vite+vue3+gin搭建的开发基础平台(支持TS,JS混用),集成jwt鉴权,权限管理,动态路由,显隐可控组件,分页封装,多点登录拦截,资源权限,上传下载,代码生成器,表单生成器,chatGPT自动查表等开发必备功能。 -
hub
A command-line tool that makes git easier to use with GitHub. -
excelize
Go language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets -
goreleaser
Deliver Go binaries as fast and easily as possible -
xlsx
(No longer maintained!) Go (golang) library for reading and writing XLSX files. -
godotenv
A Go port of Ruby's dotenv library (Loads environment variables from .env files) -
godropbox
Common libraries for writing Go services/applications. -
hystrix-go
Netflix's Hystrix latency and fault tolerance library, for Go -
go-funk
A modern Go utility library which provides helpers (map, find, contains, filter, ...) -
gorequest
GoRequest -- Simplified HTTP client ( inspired by nodejs SuperAgent ) -
goreporter
A Golang tool that does static analysis, unit testing, code review and generate code quality report. -
Kopia
Cross-platform backup tool for Windows, macOS & Linux with fast, incremental backups, client-side end-to-end encryption, compression and data deduplication. CLI and GUI included. -
gojson
Automatically generate Go (golang) struct definitions from example JSON -
lancet
A comprehensive, efficient, and reusable util function library of go. -
spinner
Go (golang) package with 90 configurable terminal spinner/progress indicators. -
create-go-app
✨ Create a new production-ready project with backend, frontend and deploy automation by running one CLI command! -
filetype
Fast, dependency-free Go package to infer binary file types based on the magic numbers header signature -
grequests
A Go "clone" of the great and famous Requests library -
EaseProbe
A simple, standalone, and lightweight tool that can do health/status checking, written in Go. -
boilr
:zap: boilerplate template manager that generates files or directories from template repositories -
sling
A Go HTTP client library for creating and sending API requests -
mole
CLI application to create ssh tunnels focused on resiliency and user experience. -
jump
Jump helps you navigate faster by learning your habits. ✌️ -
beaver
💨 A real time messaging system to build a scalable in-app notifications, multiplayer games, chat apps in web and mobile apps. -
go-underscore
Helpfully Functional Go - A useful collection of Go utilities. Designed for programmer happiness. -
gentleman
Plugin-driven, extensible HTTP client toolkit for Go -
mimetype
A fast Golang library for media type and file extension detection, based on magic numbers -
JobRunner
Framework for performing work asynchronously, outside of the request flow -
git-time-metric
Simple, seamless, lightweight time tracking for Git
Access the most powerful time series database as a service
Do you think we are missing an alternative of go-sitemap-generator or a related project?
README
A go-sitemap-generator is the easiest way to generate Sitemaps in Go.
As of version 2.0.0, This Repo is available as a Go module.
package main
import (
"github.com/ikeikeikeike/go-sitemap-generator/v2/stm"
)
func main() {
sm := stm.NewSitemap(1)
// Create method must be called first before adding entries to
// the sitemap.
sm.Create()
sm.Add(stm.URL{{"loc", "home"}, {"changefreq", "always"}, {"mobile", true}})
sm.Add(stm.URL{{"loc", "readme"}})
sm.Add(stm.URL{{"loc", "aboutme"}, {"priority", 0.1}})
sm.Finalize().PingSearchEngines()
}
Then
$ go build
Installation (Legacy download instead of a Go module.)
$ go get gopkg.in/ikeikeikeike/go-sitemap-generator.v1/stm
$ go get gopkg.in/ikeikeikeike/go-sitemap-generator.v2/stm
Features
Current Features or To-Do
- [ ] Supports: generate kind of some sitemaps.
- [x] News sitemaps
- [x] Video sitemaps
- [x] Image sitemaps
- [x] Geo sitemaps
- [x] Mobile sitemaps
- [ ] PageMap sitemap
- [x] Alternate Links
- [ ] Supports: adapters for sitemap storage.
- [x] Filesystem
- [x] S3
- [x] Customizable sitemap working
- [x] Notifies search engines (Google, Bing) of new sitemaps
- [x] Gives you complete control over your sitemap contents and naming scheme
Getting Started
Setting concurrency
To disable concurrency, set number of CPUs to 1.
sm := stm.NewSitemap(1)
If you want to set max CPUs that are available, set number of CPUs <= 0.
sm := stm.NewSitemap(0)
Preventing Output
To disable all non-essential output you can set sm.SetVerbose
to false
.
To disable output inline use the following:
sm := stm.NewSitemap(1)
sm.SetVerbose(false)
Pinging Search Engines
PingSearchEngines notifies search engines of changes once a sitemap has been generated or changed. The library will append Google and Bing to any engines passed in to the function.
sm.Finalize().PingSearchEngines()
If you want to add new search engine
, you can pass that in to the function:
sm.Finalize().PingSearchEngines("http://newengine.com/ping?url=%s")
Options
// Your website's host name
sm.SetDefaultHost("http://www.example.com")
// The remote host where your sitemaps will be hosted
sm.SetSitemapsHost("http://s3.amazonaws.com/sitemap-generator/")
// The directory to write sitemaps to locally
sm.SetPublicPath("tmp/")
// Set this to a directory/path if you don't want to upload to the root of your `SitemapsHost`
sm.SetSitemapsPath("sitemaps/")
// Struct of `S3Adapter`
sm.SetAdapter(&stm.S3Adapter{Region: "ap-northeast-1", Bucket: "your-bucket", ACL: "public-read"})
// Change the output filename
sm.SetFilename("new_filename")
Upload sitemap to S3
Recently I disabled this module here.
package main
import (
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/ikeikeikeike/go-sitemap-generator/stm"
)
func main() {
sm := stm.NewSitemap(1)
sm.SetDefaultHost("http://example.com")
sm.SetSitemapsPath("sitemap-generator") // default: public
sm.SetSitemapsHost("http://s3.amazonaws.com/sitemap-generator/")
sm.SetAdapter(&stm.S3Adapter{
Region: "ap-northeast-1",
Bucket: "your-bucket",
ACL: "public-read",
Creds: credentials.NewEnvCredentials(),
})
sm.Create()
sm.Add(stm.URL{{"loc", "home"}, {"changefreq", "always"}, {"mobile", true}})
sm.Add(stm.URL{{"loc", "readme"}})
sm.Add(stm.URL{{"loc", "aboutme"}, {"priority", 0.1}})
sm.Finalize().PingSearchEngines()
}
News sitemaps
sm.Add(stm.URL{
{"loc", "/news"},
{"news", stm.URL{
{"publication", stm.URL{
{"name", "Example"},
{"language", "en"},
},
},
{"title", "My Article"},
{"keywords", "my article, articles about myself"},
{"stock_tickers", "SAO:PETR3"},
{"publication_date", "2011-08-22"},
{"access", "Subscription"},
{"genres", "PressRelease"},
},},})
Look at Creating a Google News Sitemap as required.
Video sitemaps
sm.Add(stm.URL{
{"loc", "/videos"},
{"video", stm.URL{
{"thumbnail_loc", "http://www.example.com/video1_thumbnail.png"},
{"title", "Title"},
{"description", "Description"},
{"content_loc", "http://www.example.com/cool_video.mpg"},
{"category", "Category"},
{"tag", []string{"one", "two", "three"}},
{"player_loc", stm.Attrs{"https://example.com/p/flash/moogaloop/6.2.9/moogaloop.swf?clip_id=26", map[string]string{"allow_embed": "Yes", "autoplay": "autoplay=1"}},},
},
},
})
Look at Video sitemaps as required.
Image sitemaps
sm.Add(stm.URL{
{"loc", "/images"},
{"image", []stm.URL{
{{"loc", "http://www.example.com/image.png"}, {"title", "Image"}},
{{"loc", "http://www.example.com/image1.png"}, {"title", "Image1"}},
},},
})
Look at Image sitemaps as required.
Geo sitemaps
sm.Add(stm.URL{
{"loc", "/geos"},
{"geo", stm.URL{
{"format", "kml"},
},},
})
Couldn't find Geo sitemaps example, although it's similar to:
<url>
<loc>/geos</loc>
<geo:geo>
<geo:format>kml</geo:format>
</geo:geo>
</url>
Mobile sitemaps
sm.Add(stm.URL{{"loc", "mobiles"}, {"mobile", true}})
Look at Feature phone sitemaps as required.
Full example
package main
import (
"github.com/ikeikeikeike/go-sitemap-generator/stm"
)
func main() {
sm := stm.NewSitemap(0)
sm.SetDefaultHost("http://yourhost.com")
sm.SetSitemapsHost("http://s3.amazonaws.com/sitemaps/")
sm.SetSitemapsPath("sitemaps/")
sm.SetFilename("anothername")
sm.SetCompress(true)
sm.SetVerbose(true)
sm.SetAdapter(&stm.S3Adapter{Region: "ap-northeast-1", Bucket: "your-bucket"})
sm.Create()
sm.Add(stm.URL{{"loc", "/home"}, {"changefreq", "daily"}})
sm.Add(stm.URL{{"loc", "/abouts"}, {"mobile", true}})
sm.Add(stm.URL{{"loc", "/news"},
{"news", stm.URL{
{"publication", stm.URL{
{"name", "Example"},
{"language", "en"},
},
},
{"title", "My Article"},
{"keywords", "my article, articles about myself"},
{"stock_tickers", "SAO:PETR3"},
{"publication_date", "2011-08-22"},
{"access", "Subscription"},
{"genres", "PressRelease"},
},},
})
sm.Add(stm.URL{{"loc", "/images"},
{"image", []stm.URL{
{{"loc", "http://www.example.com/image.png"}, {"title", "Image"}},
{{"loc", "http://www.example.com/image1.png"}, {"title", "Image1"}},
},},
})
sm.Add(stm.URL{{"loc", "/videos"},
{"video", stm.URL{
{"thumbnail_loc", "http://www.example.com/video1_thumbnail.png"},
{"title", "Title"},
{"description", "Description"},
{"content_loc", "http://www.example.com/cool_video.mpg"},
{"category", "Category"},
{"tag", []string{"one", "two", "three"}},
{"player_loc", stm.Attrs{"https://example.com/p/flash/moogaloop/6.2.9/moogaloop.swf?clip_id=26", map[string]string{"allow_embed": "Yes", "autoplay": "autoplay=1"}}},
},},
})
sm.Add(stm.URL{{"loc", "/geos"},
{"geo", stm.URL{
{"format", "kml"},
},},
})
sm.Finalize().PingSearchEngines("http://newengine.com/ping?url=%s")
}
Webserver example
package main
import (
"log"
"net/http"
"github.com/ikeikeikeike/go-sitemap-generator/stm"
)
func buildSitemap() *stm.Sitemap {
sm := stm.NewSitemap(1)
sm.SetDefaultHost("http://example.com")
sm.Create()
sm.Add(stm.URL{{"loc", "/"}, {"changefreq", "daily"}})
// Note: Do not call `sm.Finalize()` because it flushes
// the underlying data structure from memory to disk.
return sm
}
func main() {
sm := buildSitemap()
mux := http.NewServeMux()
mux.HandleFunc("/sitemap.xml", func(w http.ResponseWriter, r *http.Request) {
// Go's webserver automatically sets the correct `Content-Type` header.
w.Write(sm.XMLContent())
return
})
log.Fatal(http.ListenAndServe(":8080", mux))
}
Documentation
How to test.
Preparation:
$ go get github.com/clbanning/mxj
Run tests:
$ go test -v -cover -race ./...