package urls
import "github.com/gohugoio/hugo/tpl/urls"
Package urls provides template functions to deal with URLs.
Index ¶
- type Namespace
- func New(deps *deps.Deps) *Namespace
- func (ns *Namespace) AbsLangURL(s any) (string, error)
- func (ns *Namespace) AbsURL(s any) (string, error)
- func (ns *Namespace) Anchorize(s any) (string, error)
- func (ns *Namespace) JoinPath(elements ...any) (string, error)
- func (ns *Namespace) Parse(rawurl any) (*url.URL, error)
- func (ns *Namespace) PathEscape(s any) (string, error)
- func (ns *Namespace) PathUnescape(s any) (string, error)
- func (ns *Namespace) Ref(p any, args any) (string, error)
- func (ns *Namespace) RelLangURL(s any) (string, error)
- func (ns *Namespace) RelRef(p any, args any) (string, error)
- func (ns *Namespace) RelURL(s any) (string, error)
- func (ns *Namespace) URLize(s any) (string, error)
Types ¶
type Namespace ¶
type Namespace struct {
// contains filtered or unexported fields
}
Namespace provides template functions for the "urls" namespace.
func New ¶
New returns a new instance of the urls-namespaced template functions.
func (*Namespace) AbsLangURL ¶
AbsLangURL the string s and converts it to an absolute URL according to a page's position in the project directory structure and the current language.
func (*Namespace) AbsURL ¶
AbsURL takes the string s and converts it to an absolute URL.
func (*Namespace) Anchorize ¶
Anchorize creates sanitized anchor name version of the string s that is compatible with how your configured markdown renderer does it.
func (*Namespace) JoinPath ¶
JoinPath joins the provided elements into a URL string and cleans the result of any ./ or ../ elements. If the argument list is empty, JoinPath returns an empty string.
func (*Namespace) Parse ¶
Parse parses rawurl into a URL structure. The rawurl may be relative or absolute.
func (*Namespace) PathEscape ¶
PathEscape returns the given string, applying percent-encoding to special characters and reserved delimiters so it can be safely used as a segment within a URL path.
func (*Namespace) PathUnescape ¶
PathUnescape returns the given string, replacing all percent-encoded sequences with the corresponding unescaped characters.
func (*Namespace) Ref ¶
Ref returns the absolute URL path to a given content item from Page p.
func (*Namespace) RelLangURL ¶
RelLangURL takes the string s and prepends the relative path according to a page's position in the project directory structure and the current language.
func (*Namespace) RelRef ¶
RelRef returns the relative URL path to a given content item from Page p.
func (*Namespace) RelURL ¶
RelURL takes the string s and prepends the relative path according to a page's position in the project directory structure.
func (*Namespace) URLize ¶
URLize returns the strings s formatted as an URL.
Source Files ¶
- Version
- v0.153.4 (latest)
- Published
- Dec 28, 2025
- Platform
- linux/amd64
- Imports
- 8 packages
- Last checked
- 4 months ago –
Tools for package owners.