seo

package
v0.1.41 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package seo provides SEO optimization for GoSPA projects. Includes meta tags, sitemap generation, structured data (JSON-LD), and Open Graph.

Index

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 OpenGraph added in v0.1.7

func OpenGraph(p OGParams) templ.Component

OpenGraph returns a component with Open Graph tags.

func StructuredData

func StructuredData(data any) templ.Component

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 OGParams added in v0.1.7

type OGParams struct {
	Type        string
	Title       string
	Description string
	Image       string
	URL         string
}

OGParams represents parameters for the OpenGraph component.

type Organization added in v0.1.7

type Organization struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

Organization represents JSON-LD Organization data.

type PageSEO

type PageSEO = MetaConfig

PageSEO is an alias for MetaConfig.

type Plugin added in v0.1.23

type Plugin struct {
	// contains filtered or unexported fields
}

Plugin provides SEO optimization capabilities.

func New

func New(cfg *Config) *Plugin

New creates a new SEO plugin.

func (*Plugin) Commands added in v0.1.23

func (p *Plugin) Commands() []plugin.Command

Commands returns custom CLI commands.

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

func (p *Plugin) GeneratePageMeta(page PageSEO) string

GeneratePageMeta generates meta tags for a specific page.

func (*Plugin) GetConfig added in v0.1.23

func (p *Plugin) GetConfig() *Config

GetConfig returns the current configuration.

func (*Plugin) Init added in v0.1.23

func (p *Plugin) Init() error

Init initializes the SEO plugin.

func (*Plugin) Name added in v0.1.23

func (p *Plugin) Name() string

Name returns the plugin name.

func (*Plugin) OnHook added in v0.1.23

func (p *Plugin) OnHook(hook plugin.Hook, ctx map[string]interface{}) error

OnHook handles lifecycle hooks.

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.

type TwitterParams added in v0.1.7

type TwitterParams struct {
	Card        string
	Title       string
	Description string
	Image       string
	Site        string
}

TwitterParams represents parameters for the TwitterCard component.

Jump to

Keyboard shortcuts

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