sosolyht / go-sitemap

Go sitemap generator A flexible library for creating sitemap and google video sitemaps in Go
MIT License
5 stars 0 forks source link
go go-sitemap sitemap sitemap-generator

Go Report Card

Go Sitemap Generator

A flexible library for creating sitemap and google video sitemaps in Go

Installation

go get -u github.com/sosolyht/go-sitemap/sitemap

Usage

Here is an example of how to use the Go Sitemap Generator library to create both standard and video sitemaps.

package main

import "github.com/sosolyht/go-sitemap/sitemap"

func main() {
// Create a sitemap with path
s := sitemap.NewSitemap().Path("util/sitemaps")

    links := []string{
        "https://google.com",
        "https://naver.com",
    }
    for _, link := range links {
        s.AddURL(link)
    }

    // Create a video sitemap
    vs := sitemap.NewVideoSitemap()

    videoURLs := []sitemap.VideoURL{
        // ... (the example video URLs)
    }

    for _, videoURL := range videoURLs {
        vs.AddVideoURL(videoURL)
    }
}

Replace the videoURLs variable with your video URLs and their respective video information. The sitemaps will be generated and saved as sitemaps/sitemap.xml and sitemaps/sitemap_video.xml respectively.