{"id":37089192,"url":"https://github.com/yext/go-sitemap-generator","last_synced_at":"2026-01-14T10:56:43.757Z","repository":{"id":57644081,"uuid":"439124377","full_name":"yext/go-sitemap-generator","owner":"yext","description":"go-sitemap-generator is the easiest way to generate Sitemaps in Go","archived":false,"fork":true,"pushed_at":"2025-03-04T21:35:34.000Z","size":132,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-04T22:28:44.788Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/ikeikeikeike/go-sitemap-generator","language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"ikeikeikeike/go-sitemap-generator","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yext.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-16T20:54:52.000Z","updated_at":"2025-03-04T21:35:37.000Z","dependencies_parsed_at":"2023-02-14T01:31:36.730Z","dependency_job_id":null,"html_url":"https://github.com/yext/go-sitemap-generator","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/yext/go-sitemap-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yext%2Fgo-sitemap-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yext%2Fgo-sitemap-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yext%2Fgo-sitemap-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yext%2Fgo-sitemap-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yext","download_url":"https://codeload.github.com/yext/go-sitemap-generator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yext%2Fgo-sitemap-generator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28417773,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-14T10:56:42.685Z","updated_at":"2026-01-14T10:56:43.751Z","avatar_url":"https://github.com/yext.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nA go-sitemap-generator is the easiest way to generate Sitemaps in Go.\n\nAs of version 2.0.0, This Repo is available as a [Go module](https://github.com/golang/go/wiki/Modules).\n\n\n[![GoDoc](https://godoc.org/github.com/ikeikeikeike/go-sitemap-generator/stm?status.svg)](https://godoc.org/github.com/ikeikeikeike/go-sitemap-generator/stm) [![Build Status](https://travis-ci.org/ikeikeikeike/go-sitemap-generator.svg)](https://travis-ci.org/ikeikeikeike/go-sitemap-generator)\n\n```go\npackage main\n\nimport (\n\t\"github.com/ikeikeikeike/go-sitemap-generator/v2/stm\"\n)\n\n\nfunc main() {\n\tsm := stm.NewSitemap(1)\n\n\t// Create method must be called first before adding entries to\n\t// the sitemap.\n\tsm.Create()\n\n\tsm.Add(stm.URL{{\"loc\", \"home\"}, {\"changefreq\", \"always\"}, {\"mobile\", true}})\n\tsm.Add(stm.URL{{\"loc\", \"readme\"}})\n\tsm.Add(stm.URL{{\"loc\", \"aboutme\"}, {\"priority\", 0.1}})\n\n\tsm.Finalize().PingSearchEngines()\n}\n```\n\nThen\n\n```console\n$ go build\n```\n\n#### Installation (Legacy download instead of a [Go module](https://github.com/golang/go/wiki/Modules).)\n\n```console\n$ go get gopkg.in/ikeikeikeike/go-sitemap-generator.v1/stm\n$ go get gopkg.in/ikeikeikeike/go-sitemap-generator.v2/stm\n```\n\n### Features\n\nCurrent Features or To-Do\n\n- [ ] Supports: generate kind of some sitemaps.\n  - [x] [News sitemaps](#news-sitemaps)\n  - [x] [Video sitemaps](#video-sitemaps)\n  - [x] [Image sitemaps](#image-sitemaps)\n  - [x] [Geo sitemaps](#geo-sitemaps)\n  - [x] [Mobile sitemaps](#mobile-sitemaps)\n  - [ ] PageMap sitemap\n  - [x] Alternate Links\n- [ ] Supports: adapters for sitemap storage.\n  - [x] Filesystem\n  - [x] [S3](#upload-sitemap-to-s3)\n- [x] [Customizable sitemap working](#preventing-output)\n- [x] [Notifies search engines (Google, Bing) of new sitemaps](#pinging-search-engines)\n- [x] [Gives you complete control over your sitemap contents and naming scheme](#full-example)\n\n\n## Getting Started\n\n### Setting concurrency\nTo disable concurrency, set number of CPUs to 1.\n```go\nsm := stm.NewSitemap(1)\n```\n\nIf you want to set max CPUs that are available, set number of CPUs \u003c= 0.\n```go\nsm := stm.NewSitemap(0)\n```\n\n### Preventing Output\n\nTo disable all non-essential output you can set `sm.SetVerbose` to `false`.\nTo disable output inline use the following:\n\n```go\nsm := stm.NewSitemap(1)\nsm.SetVerbose(false)\n```\n\n### Pinging Search Engines\n\nPingSearchEngines notifies search engines of changes once a sitemap\nhas been generated or changed. The library will append Google and Bing to any engines passed in to the function.\n\n```go\nsm.Finalize().PingSearchEngines()\n```\n\nIf you want to add `new search engine`, you can pass that in to the function:\n\n```go\nsm.Finalize().PingSearchEngines(\"http://newengine.com/ping?url=%s\")\n```\n\n### Options\n\n```go\n// Your website's host name\nsm.SetDefaultHost(\"http://www.example.com\")\n\n// The remote host where your sitemaps will be hosted\nsm.SetSitemapsHost(\"http://s3.amazonaws.com/sitemap-generator/\")\n\n// The directory to write sitemaps to locally\nsm.SetPublicPath(\"tmp/\")\n\n// Set this to a directory/path if you don't want to upload to the root of your `SitemapsHost`\nsm.SetSitemapsPath(\"sitemaps/\")\n\n// Struct of `S3Adapter`\nsm.SetAdapter(\u0026stm.S3Adapter{Region: \"ap-northeast-1\", Bucket: \"your-bucket\", ACL: \"public-read\"})\n\n// Change the output filename\nsm.SetFilename(\"new_filename\")\n```\n\n### Upload sitemap to S3\n\nRecently I disabled this module [here](https://github.com/ikeikeikeike/go-sitemap-generator/blob/master/stm/_adapter_s3.go).\n\n```go\npackage main\n\nimport (\n\t\"github.com/aws/aws-sdk-go/aws/credentials\"\n\t\"github.com/ikeikeikeike/go-sitemap-generator/stm\"\n)\n\nfunc main() {\n\tsm := stm.NewSitemap(1)\n\tsm.SetDefaultHost(\"http://example.com\")\n\tsm.SetSitemapsPath(\"sitemap-generator\") // default: public\n\tsm.SetSitemapsHost(\"http://s3.amazonaws.com/sitemap-generator/\")\n\tsm.SetAdapter(\u0026stm.S3Adapter{\n\t\tRegion: \"ap-northeast-1\",\n\t\tBucket: \"your-bucket\",\n\t\tACL:    \"public-read\",\n\t\tCreds:  credentials.NewEnvCredentials(),\n\t})\n\n\tsm.Create()\n\n\tsm.Add(stm.URL{{\"loc\", \"home\"}, {\"changefreq\", \"always\"}, {\"mobile\", true}})\n\tsm.Add(stm.URL{{\"loc\", \"readme\"}})\n\tsm.Add(stm.URL{{\"loc\", \"aboutme\"}, {\"priority\", 0.1}})\n\n\tsm.Finalize().PingSearchEngines()\n}\n```\n\n### News sitemaps\n\n```go\nsm.Add(stm.URL{\n\t{\"loc\", \"/news\"},\n\t{\"news\", stm.URL{\n\t{\"publication\", stm.URL{\n\t\t{\"name\",     \"Example\"},\n\t\t{\"language\", \"en\"},\n\t},\n\t},\n\t{\"title\",            \"My Article\"},\n\t{\"keywords\",         \"my article, articles about myself\"},\n\t{\"stock_tickers\",    \"SAO:PETR3\"},\n\t{\"publication_date\", \"2011-08-22\"},\n\t{\"access\",           \"Subscription\"},\n\t{\"genres\",           \"PressRelease\"},\n},},})\n```\n\nLook at [Creating a Google News Sitemap](https://support.google.com/news/publisher/answer/74288) as required.\n\n### Video sitemaps\n\n```go\nsm.Add(stm.URL{\n\t{\"loc\", \"/videos\"},\n\t{\"video\", stm.URL{\n\t{\"thumbnail_loc\", \"http://www.example.com/video1_thumbnail.png\"},\n\t{\"title\",         \"Title\"},\n\t{\"description\",   \"Description\"},\n\t{\"content_loc\",   \"http://www.example.com/cool_video.mpg\"},\n\t{\"category\",      \"Category\"},\n\t{\"tag\",           []string{\"one\", \"two\", \"three\"}},\n    {\"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\"}},},\n},\n},\n})\n```\n\nLook at [Video sitemaps](https://support.google.com/webmasters/answer/80471) as required.\n\n### Image sitemaps\n\n```go\nsm.Add(stm.URL{\n\t{\"loc\", \"/images\"},\n\t{\"image\", []stm.URL{\n\t{{\"loc\", \"http://www.example.com/image.png\"}, {\"title\", \"Image\"}},\n\t{{\"loc\", \"http://www.example.com/image1.png\"}, {\"title\", \"Image1\"}},\n},},\n})\n\n```\n\nLook at [Image sitemaps](https://support.google.com/webmasters/answer/178636) as required.\n\n### Geo sitemaps\n\n```go\nsm.Add(stm.URL{\n\t{\"loc\", \"/geos\"},\n\t{\"geo\", stm.URL{\n\t{\"format\", \"kml\"},\n},},\n})\n```\n\nCouldn't find Geo sitemaps example, although it's similar to:\n\n```xml\n\u003curl\u003e\n\t\u003cloc\u003e/geos\u003c/loc\u003e\n\t\u003cgeo:geo\u003e\n\t\t\u003cgeo:format\u003ekml\u003c/geo:format\u003e\n\t\u003c/geo:geo\u003e\n\u003c/url\u003e\n```\n\n### Mobile sitemaps\n\n```go\nsm.Add(stm.URL{{\"loc\", \"mobiles\"}, {\"mobile\", true}})\n```\n\nLook at [Feature phone sitemaps](https://support.google.com/webmasters/answer/6082207) as required.\n\n\n### Full example\n\n```go\npackage main\n\nimport (\n\t\"github.com/ikeikeikeike/go-sitemap-generator/stm\"\n)\n\nfunc main() {\n\tsm := stm.NewSitemap(0)\n\tsm.SetDefaultHost(\"http://yourhost.com\")\n\tsm.SetSitemapsHost(\"http://s3.amazonaws.com/sitemaps/\")\n\tsm.SetSitemapsPath(\"sitemaps/\")\n\tsm.SetFilename(\"anothername\")\n\tsm.SetCompress(true)\n\tsm.SetVerbose(true)\n\tsm.SetAdapter(\u0026stm.S3Adapter{Region: \"ap-northeast-1\", Bucket: \"your-bucket\"})\n\n\tsm.Create()\n\n\tsm.Add(stm.URL{{\"loc\", \"/home\"}, {\"changefreq\", \"daily\"}})\n\n\tsm.Add(stm.URL{{\"loc\", \"/abouts\"}, {\"mobile\", true}})\n\n\tsm.Add(stm.URL{{\"loc\", \"/news\"},\n\t{\"news\", stm.URL{\n\t\t{\"publication\", stm.URL{\n\t\t\t{\"name\",     \"Example\"},\n\t\t\t{\"language\", \"en\"},\n\t\t},\n\t\t},\n\t\t{\"title\",            \"My Article\"},\n\t\t{\"keywords\",         \"my article, articles about myself\"},\n\t\t{\"stock_tickers\",    \"SAO:PETR3\"},\n\t\t{\"publication_date\", \"2011-08-22\"},\n\t\t{\"access\",           \"Subscription\"},\n\t\t{\"genres\",           \"PressRelease\"},\n\t},},\n\t})\n\n\tsm.Add(stm.URL{{\"loc\", \"/images\"},\n\t{\"image\", []stm.URL{\n\t\t{{\"loc\", \"http://www.example.com/image.png\"}, {\"title\", \"Image\"}},\n\t\t{{\"loc\", \"http://www.example.com/image1.png\"}, {\"title\", \"Image1\"}},\n\t},},\n\t})\n\n\tsm.Add(stm.URL{{\"loc\", \"/videos\"},\n\t{\"video\", stm.URL{\n\t\t{\"thumbnail_loc\", \"http://www.example.com/video1_thumbnail.png\"},\n\t\t{\"title\",         \"Title\"},\n\t\t{\"description\",   \"Description\"},\n\t\t{\"content_loc\",   \"http://www.example.com/cool_video.mpg\"},\n\t\t{\"category\",      \"Category\"},\n\t\t{\"tag\",           []string{\"one\", \"two\", \"three\"}},\n\t    {\"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\"}}},\n\t},},\n\t})\n\n\tsm.Add(stm.URL{{\"loc\", \"/geos\"},\n\t{\"geo\", stm.URL{\n\t\t{\"format\", \"kml\"},\n\t},},\n\t})\n\n\tsm.Finalize().PingSearchEngines(\"http://newengine.com/ping?url=%s\")\n}\n```\n\n### Webserver example\n\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"net/http\"\n\n\t\"github.com/ikeikeikeike/go-sitemap-generator/stm\"\n)\n\nfunc buildSitemap() *stm.Sitemap {\n\tsm := stm.NewSitemap(1)\n\tsm.SetDefaultHost(\"http://example.com\")\n\n\tsm.Create()\n\tsm.Add(stm.URL{{\"loc\", \"/\"}, {\"changefreq\", \"daily\"}})\n\n\t// Note: Do not call `sm.Finalize()` because it flushes\n\t// the underlying data structure from memory to disk.\n\n\treturn sm\n}\n\nfunc main() {\n\tsm := buildSitemap()\n\n\tmux := http.NewServeMux()\n\tmux.HandleFunc(\"/sitemap.xml\", func(w http.ResponseWriter, r *http.Request) {\n\t\t// Go's webserver automatically sets the correct `Content-Type` header.\n\t\tw.Write(sm.XMLContent())\n\t\treturn\n\t})\n\n\tlog.Fatal(http.ListenAndServe(\":8080\", mux))\n}\n```\n\n\n### Documentation\n\n- [API Reference](https://godoc.org/github.com/ikeikeikeike/go-sitemap-generator/stm)\n- [sitemap_generator](http://github.com/kjvarga/sitemap_generator)\n\n### How to test.\n\nPreparation:\n\n```console\n$ go get github.com/clbanning/mxj\n```\n\nRun tests:\n\n```console\n$ go test -v -cover -race ./...\n```\n\n#### Inspired by [sitemap_generator](http://github.com/kjvarga/sitemap_generator)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyext%2Fgo-sitemap-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyext%2Fgo-sitemap-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyext%2Fgo-sitemap-generator/lists"}