meta

package
v0.3.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TagOpen = []byte("<meta")

	AttrName      = []byte(" name=\"")
	AttrContent   = []byte(" content=\"")
	AttrCharset   = []byte(" charset=\"")
	AttrHttpEquiv = []byte(" http-equiv=\"")
	AttrScheme    = []byte(" scheme=\"")
	AttrProperty  = []byte(" property=\"")
	AttrMedia     = []byte(" media=\"")
)

Byte constants for HTML rendering.

Functions

func Author

func Author(content string) *element

Author Creates a meta author element to identify the document's author. Example: meta.Author("John Doe") Renders: <meta name="author" content="John Doe" />

func CSP added in v0.3.0

func CSP(policy string) *element

CSP Creates a meta element that sets a Content-Security-Policy for the document. Restricts which resources the browser is allowed to load, helping prevent XSS and data injection attacks. Example: meta.CSP("default-src 'self'; script-src 'self'") Renders: <meta content="default-src 'self'; script-src 'self'" http-equiv="Content-Security-Policy" />

func Charset

func Charset(charset charset.Charset) *element

Charset Creates a new meta element declaring character encoding. Example: meta.Charset(charset.Custom("custom")) Renders: <meta charset="custom" />

func Description

func Description(content string) *element

Description Creates a meta description element for SEO and search engine snippets. Example: meta.Description("Page description") Renders: <meta name="description" content="Page description" />

func HttpEquiv added in v0.3.0

func HttpEquiv(directive string, content string) *element

HttpEquiv Creates a meta element with an http-equiv directive and content value. Covers directives not wrapped by dedicated constructors like CSP or Refresh. Example: meta.HttpEquiv("X-UA-Compatible", "IE=edge") Renders: <meta content="IE=edge" http-equiv="X-UA-Compatible" />

func Keywords

func Keywords(content string) *element

Keywords Creates a meta keywords element (largely deprecated for SEO). Example: meta.Keywords("html, css, javascript") Renders: <meta name="keywords" content="html, css, javascript" />

func New

func New() *element

New Creates a new meta element without any initial attributes. Example: meta.New() Renders: <meta />

func OG

func OG(property string, content string) *element

OG Creates a new meta element for Open Graph protocol properties (social media sharing). Example: meta.OG("title", "My Page Title") Renders: <meta content="My Page Title" property="og:title" />

func Refresh

func Refresh(seconds int, url string) *element

Refresh Creates a meta refresh element that automatically redirects after specified seconds. Example: meta.Refresh(5, "/new-page") Renders: <meta content="5; url=/new-page" http-equiv="refresh" />

func Robots

func Robots(content string) *element

Robots Creates a meta robots element to control search engine crawling and indexing. Example: meta.Robots("index, follow") Renders: <meta name="robots" content="index, follow" />

func ThemeColor added in v0.3.0

func ThemeColor(color string) *element

ThemeColor Creates a meta element that sets the browser theme colour for the page. Used by mobile browsers and PWAs to colour the address bar and other UI chrome. Combine with the Media attribute for dark mode support. Example: meta.ThemeColor("#1a1a2e") Renders: <meta name="theme-color" content="#1a1a2e" />

func UTF8

func UTF8() *element

UTF8 Creates a UTF-8 charset meta element (recommended encoding). Example: meta.UTF8() Renders: <meta charset="UTF-8" />

func Viewport

func Viewport(content string) *element

Viewport Creates a new meta element for viewport configuration on mobile devices. Example: meta.Viewport("width=device-width, initial-scale=1.0") Renders: <meta name="viewport" content="width=device-width, initial-scale=1.0" />

Types

type Element

type Element = element

Element is an exported alias for the private element type

Jump to

Keyboard shortcuts

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