link

package
v0.3.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 26 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

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

	AttrRel            = []byte(" rel=\"")
	AttrHref           = []byte(" href=\"")
	AttrAs             = []byte(" as=\"")
	AttrCrossOrigin    = []byte(" crossorigin=\"")
	AttrDisabled       = []byte(" disabled")
	AttrHrefLang       = []byte(" hreflang=\"")
	AttrIntegrity      = []byte(" integrity=\"")
	AttrMedia          = []byte(" media=\"")
	AttrReferrerPolicy = []byte(" referrerpolicy=\"")
	AttrSizes          = []byte(" sizes=\"")
	AttrTitle          = []byte(" title=\"")
	AttrType           = []byte(" type=\"")
	AttrFetchPriority  = []byte(" fetchpriority=\"")
	AttrBlocking       = []byte(" blocking=\"")
	AttrImageSrcset    = []byte(" imagesrcset=\"")
	AttrImageSizes     = []byte(" imagesizes=\"")
	AttrColor          = []byte(" color=\"")
)

Byte constants for HTML rendering.

Functions

func Canonical added in v0.3.0

func Canonical(href string) *element

Canonical Creates a link element declaring the canonical URL for the page. Important for SEO when the same content is accessible at multiple URLs. Search engines use this to consolidate ranking signals. Example: link.Canonical("https://example.com/page") Renders: <link rel="canonical" href="https://example.com/page" />

func Icon

func Icon(href string) *element

Icon Creates a new link element for a site icon (favicon). Example: link.Icon("/favicon.ico") Renders: <link rel="icon" href="/favicon.ico" />

func New

func New() *element

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

func Prefetch added in v0.3.0

func Prefetch(href string) *element

Prefetch Creates a link element that hints the browser to prefetch a resource the user is likely to navigate to next. The resource is fetched at low priority during idle time and cached for future use. Example: link.Prefetch("/next-page") Renders: <link rel="prefetch" href="/next-page" />

func Preload

func Preload(href string, as as.As) *element

Preload Creates a new link element for preloading resources to improve performance. Example: link.Preload("/font.woff2", as.Font) Renders: <link rel="preload" href="/font.woff2" as="font" />

func Stylesheet

func Stylesheet(href string) *element

Stylesheet Creates a new link element for a CSS stylesheet. Example: link.Stylesheet("/styles.css") Renders: <link rel="stylesheet" href="/styles.css" />

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