sitemap

package
v1.8.18 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package sitemap generates site mappings and a mapping indexes that can be rendered in XML. Sitemaps are used to direct search engines how to navigate their site crawls. As Defacto2 has 100,000s of hyperlinks with many generated from the database. We need to limit the search engines to avoid them wasting their crawl quote on duplicated linkage.

Useful links,

Index

Constants

View Source
const (
	Namespace = "http://www.sitemaps.org/schemas/sitemap/0.9"
	RootURL   = "https://defacto2.net"
	Website   = "sitemap.xml"
	Releaser  = "sitemap-releaser.xml"
	Magazine  = "sitemap-magazine.xml"
	BBS       = "sitemap-bbs.xml"
	FTP       = "sitemap-ftp.xml"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

type Index struct {
	XMLName xml.Name `xml:"sitemapindex"`
	XMLNS   string   `xml:"xmlns,attr"`
	Maps    []Map
}

Index is a xml sitemap index file that is a centralized collection of all the sitemaps used on the site.

An example output:

<?xml version="1.0" encoding="UTF-8"?> <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

<sitemap>
	<loc>https://www.example.com/sitemap1.xml.gz</loc>
	<lastmod>2024-08-15</lastmod>
</sitemap>
<sitemap>
	<loc>https://www.example.com/sitemap2.xml.gz</loc>
	<lastmod>2022-06-05</lastmod>
</sitemap>

</sitemapindex>

See package documentation for links.

func MapIndex

func MapIndex() *Index

MapIndex generates the sitemap index xml page. It must be handled by either the XML or XMLPretty echo contexts.

type Loc

type Loc struct {
	XMLName xml.Name `xml:"url"`
	Loc     string   `xml:"loc"`
	LastMod string   `xml:"lastmod,omitempty"`
}

Loc is the URL location of the website page.

type Map

type Map struct {
	XMLName xml.Name `xml:"sitemap"`
	Loc     string   `xml:"loc"`
	LastMod string   `xml:"lastmod,omitempty"`
}

Map is the URL location of the sitemap.

type Sitemap

type Sitemap struct {
	XMLName xml.Name `xml:"urlset"`
	XMLNS   string   `xml:"xmlns,attr"`
	Locs    []Loc
}

Sitemap is an xml sitemap file that links to the all the website pages that should be crawled and index by search engines.

An example output:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

<url>
  <loc>https://www.example.com/foo.html</loc>
  <lastmod>2022-06-04</lastmod>
</url>

</urlset>

See package documentation for links.

func MapBBS

func MapBBS(db *sql.DB, sl *slog.Logger) *Sitemap

MapBBS generates the sitemap that links to every bbs page that is public. It must be handled by either the XML or XMLPretty echo contexts.

func MapFTP

func MapFTP(db *sql.DB, sl *slog.Logger) *Sitemap

MapFTP generates the sitemap that links to every ftp page that is public. It must be handled by either the XML or XMLPretty echo contexts.

func MapMagzine

func MapMagzine(db *sql.DB, sl *slog.Logger) *Sitemap

MapMagazine generates the sitemap that links to every magazine page that is public. It must be handled by either the XML or XMLPretty echo contexts.

func MapReleaser

func MapReleaser(db *sql.DB, sl *slog.Logger) *Sitemap

MapReleaser generates the sitemap that links to every releaser page that is public. It must be handled by either the XML or XMLPretty echo contexts.

func MapSite

func MapSite(db *sql.DB, sl *slog.Logger) *Sitemap

MapSite generates the main sitemap for the website. It must be handled by either the XML or XMLPretty echo contexts.

Jump to

Keyboard shortcuts

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