Documentation
¶
Overview ¶
Package seo renders SEO metadata, public sitemaps and robots.txt.
When the redirects module is registered, sitemap entries use the final same-origin URL after native redirect resolution. Redirect targets must be declared indexable entries or localized listings with indexable public items; unknown, protected, external and cyclic destinations are omitted. Generating a sitemap never requests redirect destinations or increments their hit counts.
Index ¶
Constants ¶
const ( SettingSiteTitle = "site.title" SettingSiteTagline = "site.tagline" SettingSiteBaseURL = "site.base_url" SettingTitleTemplate = "seo.title_template" SettingDefaultDescription = "seo.default_description" SettingDefaultOGImage = "seo.default_og_image" SettingRobotsTxt = "seo.robots_txt" // DefaultTitleTemplate formats page titles; {title} and {site} are // replaced. DefaultTitleTemplate = "{title} – {site}" )
Settings keys read by the service (site.* are owned by the admin module).
const FilterSitemapEntry = "seo.sitemap_entry"
FilterSitemapEntry runs for every sitemap entry with a *SitemapEntry whose Loc is the fallback path (menus.ContentPath / TermPath / ArchivePath). Filters may rewrite Loc (a site path or absolute URL) or clear it to drop the entry, and must return the *SitemapEntry. The theme module subscribes and sets Loc to the theme permalink.
Variables ¶
This section is empty.
Functions ¶
func DefaultRobots ¶
DefaultRobots is the robots.txt used when seo.robots_txt is unset.
func ValidateSetting ¶
ValidateSetting validates and normalises one Settings → SEO value exactly as the admin screen does: SettingTitleTemplate (blank → default; must contain {title}, max 200 runes), SettingDefaultDescription (max 500 runes), SettingDefaultOGImage (blank or an absolute http(s) URL) and SettingRobotsTxt (CRLF → LF, max 10 KB, no NUL). It returns the value to store or a *SettingError; other keys get code "seo.error.key".
Types ¶
type Meta ¶
type Meta struct {
Title string `json:"title"`
Description string `json:"description"`
Canonical string `json:"canonical"`
Robots string `json:"robots"`
OGTitle string `json:"og_title"`
OGDescription string `json:"og_description"`
OGImage string `json:"og_image"`
TwitterCard string `json:"twitter_card"`
Schema json.RawMessage `json:"schema,omitempty"`
}
type Module ¶
type Module struct{}
Module is the seo kernel.Module. It owns no tables (settings only) and mounts no public routes: the site/theme module serves /sitemap.xml and /robots.txt through the Service.
type SettingError ¶
type SettingError struct{ Key, Code string }
SettingError is a rejected SEO setting value; Code is an i18n key.
func (*SettingError) Error ¶
func (e *SettingError) Error() string