sitemap

package
v0.0.0-...-8d6dda1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeFreq

type ChangeFreq string
const (
	ALWAYS  ChangeFreq = "always"
	HOURLY  ChangeFreq = "hourly"
	DAILY   ChangeFreq = "daily"
	WEEKLY  ChangeFreq = "weekly"
	MONTHLY ChangeFreq = "monthly"
	YEARLY  ChangeFreq = "yearly"
)

"always", "hourly", "daily", "weekly", "monthly", "yearly"

type Sitemap

type Sitemap struct {
	Version  string //xml版本,默认1.0
	Encoding string //xml字符编码
}

func NewSitemap

func NewSitemap(version string, encoding string) *Sitemap

func (*Sitemap) CreateSitemapContent

func (this *Sitemap) CreateSitemapContent(su []SitemapUrl, file string) error

生成站点地图内容 <?xml version="1.0" encoding="utf-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> <url> <loc>http://www.baidu.com</loc> <priority>0.5</priority> <lastmod>2017-12-27</lastmod> <changefreq>weekly</changefreq> </url> </urlset>

func (*Sitemap) CreateSitemapIndex

func (this *Sitemap) CreateSitemapIndex(si []SitemapIndex, file string) error

生成站点地图索引

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex>
	<sitemap>
		<loc>http://www.wangpanzhijia.net/static/Sitemap/share-0-5000.xml</loc>
		<lastmod>2016-12-26</lastmod>
	</sitemap>
</sitemapindex>

type SitemapIndex

type SitemapIndex struct {
	Loc     string //必填,sitemap链接地址
	Lastmod string //索引最后更新时间
}

sitemap索引

type SitemapUrl

type SitemapUrl struct {
	Loc        string     //链接,必填,长度不能超过256个字符
	Lastmod    string     //链接内容最后更新时间,选填
	ChangeFreq ChangeFreq //链接更新频率,选填
	Priority   float32    //权重,0.0-1.0之间
}

sitemap链接结构

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL