Documentation
¶
Overview ¶
Package seo provides SEO optimization for GoSPA projects. Includes meta tags, sitemap generation, structured data (JSON-LD), and Open Graph.
Index ¶
- func Meta(p MetaParams) templ.Component
- func MetaTags(config MetaConfig) string
- func OpenGraph(p OGParams) templ.Component
- func StructuredData(data any) templ.Component
- func TwitterCard(p TwitterParams) templ.Component
- type ArticleData
- type Config
- type MetaConfig
- type MetaParams
- type OGParams
- type Organization
- type PageSEO
- type Plugin
- func (p *Plugin) Commands() []plugin.Command
- func (p *Plugin) Dependencies() []plugin.Dependency
- func (p *Plugin) GeneratePageMeta(page PageSEO) string
- func (p *Plugin) GetConfig() *Config
- func (p *Plugin) Init() error
- func (p *Plugin) Name() string
- func (p *Plugin) OnHook(hook plugin.Hook, ctx map[string]interface{}) error
- type RawStructuredData
- type TwitterParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Meta ¶ added in v0.1.7
func Meta(p MetaParams) templ.Component
Meta returns a component with meta tags.
func MetaTags ¶ added in v0.1.7
func MetaTags(config MetaConfig) string
MetaTags generates meta tags using the default plugin.
func StructuredData ¶
StructuredData generates JSON-LD structured data.
func TwitterCard ¶ added in v0.1.7
func TwitterCard(p TwitterParams) templ.Component
TwitterCard returns a component with Twitter Card tags.
Types ¶
type ArticleData ¶ added in v0.1.7
type ArticleData struct {
Headline string `json:"headline"`
Author string `json:"author"`
DatePublished string `json:"datePublished"`
Image string `json:"image"`
}
ArticleData represents article-specific metadata for JSON-LD.
type Config ¶
type Config struct {
// SiteURL is the base URL of the website.
SiteURL string `yaml:"site_url" json:"siteUrl"`
// SiteName is the name of the website.
SiteName string `yaml:"site_name" json:"siteName"`
// DefaultTitle is the default page title.
DefaultTitle string `yaml:"default_title" json:"defaultTitle"`
// DefaultDescription is the default meta description.
DefaultDescription string `yaml:"default_description" json:"defaultDescription"`
// DefaultImage is the default Open Graph image.
DefaultImage string `yaml:"default_image" json:"defaultImage"`
// TwitterHandle is the Twitter/X handle (@username).
TwitterHandle string `yaml:"twitter_handle" json:"twitterHandle"`
// Language is the default language code.
Language string `yaml:"language" json:"language"`
// OutputDir is where generated SEO files are written.
OutputDir string `yaml:"output_dir" json:"outputDir"`
// GenerateSitemap enables sitemap.xml generation.
GenerateSitemap bool `yaml:"generate_sitemap" json:"generateSitemap"`
// GenerateRobots enables robots.txt generation.
GenerateRobots bool `yaml:"generate_robots" json:"generateRobots"`
// RoutesDir is where route files are located.
RoutesDir string `yaml:"routes_dir" json:"routesDir"`
}
Config holds SEO plugin configuration.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default SEO configuration.
type MetaConfig ¶ added in v0.1.7
type MetaConfig struct {
Path string `json:"path"`
Title string `json:"title"`
Description string `json:"description"`
Image string `json:"image"`
Keywords []string `json:"keywords"`
NoIndex bool `json:"noIndex"`
NoFollow bool `json:"noFollow"`
Canonical string `json:"canonical"`
Modified string `json:"modified"`
ChangeFreq string `json:"changeFreq"`
Priority float64 `json:"priority"`
}
MetaConfig represents SEO metadata for a page.
type MetaParams ¶ added in v0.1.7
type MetaParams struct {
Title string
Description string
Keywords []string
Canonical string
OGImage string
}
MetaParams represents parameters for the Meta component.
type Organization ¶ added in v0.1.7
type Organization struct {
Name string `json:"name"`
URL string `json:"url"`
Logo string `json:"logo"`
}
Organization represents JSON-LD Organization data.
type Plugin ¶ added in v0.1.23
type Plugin struct {
// contains filtered or unexported fields
}
Plugin provides SEO optimization capabilities.
func (*Plugin) Dependencies ¶ added in v0.1.23
func (p *Plugin) Dependencies() []plugin.Dependency
Dependencies returns required dependencies.
func (*Plugin) GeneratePageMeta ¶ added in v0.1.23
GeneratePageMeta generates meta tags for a specific page.
type RawStructuredData ¶ added in v0.1.7
type RawStructuredData struct {
Type string `json:"@type"`
Context string `json:"@context"`
Properties map[string]interface{} `json:"-"`
}
RawStructuredData represents JSON-LD structured data.