hugo: Index | Files

package helpers

import ""

Package helpers implements general utility functions that work with and on content. The helper functions defined here lay down the foundation of how Hugo works with files and filepaths, and perform string operations on content.


Package Files

baseURL.go content.go content_renderer.go emoji.go general.go hugo.go language.go path.go pathspec.go pygments.go url.go


const FilePathSeparator = string(filepath.Separator)

FilePathSeparator as defined by os.Separator.


var (
    // DistinctErrorLog can be used to avoid spamming the logs with errors.
    DistinctErrorLog = NewDistinctErrorLogger()

    // DistinctWarnLog can be used to avoid spamming the logs with warnings.
    DistinctWarnLog = NewDistinctWarnLogger()

    // DistinctFeedbackLog can be used to avoid spamming the logs with info messages.
    DistinctFeedbackLog = NewDistinctFeedbackLogger()
var (
    // ErrThemeUndefined is returned when a theme has not be defined by the user.
    ErrThemeUndefined = errors.New("no theme set")

    // ErrWalkRootTooShort is returned when the root specified for a file walk is shorter than 4 characters.
    ErrWalkRootTooShort = errors.New("Path too short. Stop walking.")
var CurrentHugoVersion = HugoVersion{
    Number:     0.31,
    PatchLevel: 0,
    Suffix:     "-DEV",

CurrentHugoVersion represents the current build version. This should be the only one.

var SummaryDivider = []byte("<!--more-->")

SummaryDivider denotes where content summarization should end. The default is "<!--more-->".

func AddContextRoot Uses

func AddContextRoot(baseURL, relativePath string) string

AddContextRoot adds the context root to an URL if it's not already set. For relative URL entries on sites with a base url with a context root set (i.e., relative URLs must not include the context root if canonifyURLs is enabled. But if it's disabled, it must be set.

func BytesToHTML Uses

func BytesToHTML(b []byte) template.HTML

BytesToHTML converts bytes to type template.HTML.

func CompareVersion Uses

func CompareVersion(version interface{}) int

CompareVersion compares the given version string or number against the running Hugo version. It returns -1 if the given version is less than, 0 if equal and 1 if greater than the running version.

func Deprecated Uses

func Deprecated(object, item, alternative string, err bool)

Deprecated informs about a deprecation, but only once for a given set of arguments' values. If the err flag is enabled, it logs as an ERROR (will exit with -1) and the text will point at the next Hugo release. The idea is two remove an item in two Hugo releases to give users and theme authors plenty of time to fix their templates.

func DiffStringSlices Uses

func DiffStringSlices(slice1 []string, slice2 []string) []string

DiffStringSlices returns the difference between two string slices. Useful in tests. See:

func DirExists Uses

func DirExists(path string, fs afero.Fs) (bool, error)

DirExists checks if a path exists and is a directory.

func Emojify Uses

func Emojify(source []byte) []byte

Emojify "emojifies" the input source. Note that the input byte slice will be modified if needed. See

func Exists Uses

func Exists(path string, fs afero.Fs) (bool, error)

Exists checks if a file or directory exists.

func Ext Uses

func Ext(in string) string

Ext takes a path and returns the extension, including the delmiter, i.e. ".md".

func ExtractRootPaths Uses

func ExtractRootPaths(paths []string) []string

ExtractRootPaths extracts the root paths from the supplied list of paths. The resulting root path will not contain any file separators, but there may be duplicates. So "/content/section/" becomes "content"

func ExtractTOC Uses

func ExtractTOC(content []byte) (newcontent []byte, toc []byte)

ExtractTOC extracts Table of Contents from content.

func FileContains Uses

func FileContains(filename string, subslice []byte, fs afero.Fs) (bool, error)

FileContains checks if a file contains a specified string.

func FileContainsAny Uses

func FileContainsAny(filename string, subslices [][]byte, fs afero.Fs) (bool, error)

FileContainsAny checks if a file contains any of the specified strings.

func Filename Uses

func Filename(in string) (name string)

Filename takes a path, strips out the extension, and returns the name of the file.

func FindAvailablePort Uses

func FindAvailablePort() (*net.TCPAddr, error)

FindAvailablePort returns an available and valid TCP port.

func FindCWD Uses

func FindCWD() (string, error)

FindCWD returns the current working directory from where the Hugo executable is run.

func FirstUpper Uses

func FirstUpper(s string) string

FirstUpper returns a string with the first character as upper case.

func GetDottedRelativePath Uses

func GetDottedRelativePath(inPath string) string

GetDottedRelativePath expects a relative path starting after the content directory. It returns a relative path with dots ("..") navigating up the path structure.

func GetRealPath Uses

func GetRealPath(fs afero.Fs, path string) (string, error)

GetRealPath returns the real file path for the given path, whether it is a symlink or not.

func GetRelativePath Uses

func GetRelativePath(path, base string) (final string, err error)

GetRelativePath returns the relative path of a given path.

func GetTempDir Uses

func GetTempDir(subPath string, fs afero.Fs) string

GetTempDir returns a temporary directory with the given sub path.

func GetTitleFunc Uses

func GetTitleFunc(style string) func(s string) string

GetTitleFunc returns a func that can be used to transform a string to title case.

The supported styles are

- "Go" (strings.Title) - "AP" (see - "Chicago" (see

If an unknown or empty style is provided, AP style is what you get.

func GuessSection Uses

func GuessSection(in string) string

GuessSection returns the section given a source path. A section is the part between the root slash and the second slash or before the first slash.

func GuessType Uses

func GuessType(in string) string

GuessType attempts to guess the type of file from a given string.

func HasAsciidoc Uses

func HasAsciidoc() bool

HasAsciidoc returns whether Asciidoc is installed on this computer.

func HasAsciidoctor Uses

func HasAsciidoctor() bool

HasAsciidoctor returns whether Asciidoctor is installed on this computer.

func HasRst Uses

func HasRst() bool

HasRst returns whether rst2html is installed on this computer.

func HasStringsPrefix Uses

func HasStringsPrefix(s, prefix []string) bool

HasStringsPrefix tests whether the string slice s begins with prefix slice s.

func HasStringsSuffix Uses

func HasStringsSuffix(s, suffix []string) bool

HasStringsSuffix tests whether the string slice s ends with suffix slice s.

func InStringArray Uses

func InStringArray(arr []string, el string) bool

InStringArray checks if a string is an element of a slice of strings and returns a boolean value.

func InitLoggers Uses

func InitLoggers()

InitLoggers sets up the global distinct loggers.

func IsAbsURL Uses

func IsAbsURL(path string) bool

IsAbsURL determines whether the given path points to an absolute URL.

func IsDir Uses

func IsDir(path string, fs afero.Fs) (bool, error)

IsDir checks if a given path is a directory.

func IsEmpty Uses

func IsEmpty(path string, fs afero.Fs) (bool, error)

IsEmpty checks if a given path is empty.

func IsWhitespace Uses

func IsWhitespace(r rune) bool

IsWhitespace determines if the given rune is whitespace.

func MakePermalink(host, plink string) *url.URL

MakePermalink combines base URL with content path to create full URL paths. Example

path:   post/how-i-blog

func MakeTitle Uses

func MakeTitle(inpath string) string

MakeTitle converts the path given to a suitable title, trimming whitespace and replacing hyphens with whitespace.

func Md5String Uses

func Md5String(f string) string

Md5String takes a string and returns its MD5 hash.

func NormalizeHugoFlags Uses

func NormalizeHugoFlags(f *pflag.FlagSet, name string) pflag.NormalizedName

NormalizeHugoFlags facilitates transitions of Hugo command-line flags, e.g. --baseUrl to --baseURL, --uglyUrls to --uglyURLs

func PathPrep Uses

func PathPrep(ugly bool, in string) string

PathPrep prepares the path using the uglify setting to create paths on either the form /section/name/index.html or /section/name.html.

func PrettifyPath Uses

func PrettifyPath(in string) string

PrettifyPath is the same as PrettifyURLPath but for file paths.

/section/name.html       becomes /section/name/index.html
/section/name/           becomes /section/name/index.html
/section/name/index.html becomes /section/name/index.html

func PrettifyURL Uses

func PrettifyURL(in string) string

PrettifyURL takes a URL string and returns a semantic, clean URL.

func PrettifyURLPath Uses

func PrettifyURLPath(in string) string

PrettifyURLPath takes a URL path to a content and converts it to enable pretty URLs.

/section/name.html       becomes /section/name/index.html
/section/name/           becomes /section/name/index.html
/section/name/index.html becomes /section/name/index.html

func ReaderContains Uses

func ReaderContains(r io.Reader, subslice []byte) bool

ReaderContains reports whether subslice is within r.

func ReaderToBytes Uses

func ReaderToBytes(lines io.Reader) []byte

ReaderToBytes takes an io.Reader argument, reads from it and returns bytes.

func ReaderToString Uses

func ReaderToString(lines io.Reader) string

ReaderToString is the same as ReaderToBytes, but returns a string.

func ReplaceExtension Uses

func ReplaceExtension(path string, newExt string) string

ReplaceExtension takes a path and an extension, strips the old extension and returns the path with the new extension.

func SafeWriteToDisk Uses

func SafeWriteToDisk(inpath string, r io.Reader, fs afero.Fs) (err error)

SafeWriteToDisk is the same as WriteToDisk but it also checks to see if file/directory already exists.

func SanitizeURL Uses

func SanitizeURL(in string) string

SanitizeURL sanitizes the input URL string.

func SanitizeURLKeepTrailingSlash Uses

func SanitizeURLKeepTrailingSlash(in string) string

SanitizeURLKeepTrailingSlash is the same as SanitizeURL, but will keep any trailing slash.

func SliceToLower Uses

func SliceToLower(s []string) []string

SliceToLower goes through the source slice and lowers all values.

func StripHTML Uses

func StripHTML(s string) string

StripHTML accepts a string, strips out all HTML tags and returns it.

func SymbolicWalk Uses

func SymbolicWalk(fs afero.Fs, root string, walker filepath.WalkFunc) error

SymbolicWalk is like filepath.Walk, but it supports the root being a symbolic link. It will still not follow symbolic links deeper down in the file structure.

func ToLowerMap Uses

func ToLowerMap(m map[string]interface{})

ToLowerMap makes all the keys in the given map lower cased and will do so recursively. Notes: * This will modify the map given. * Any nested map[interface{}]interface{} will be converted to map[string]interface{}.

func TotalWords Uses

func TotalWords(s string) int

TotalWords counts instance of one or more consecutive white space characters, as defined by unicode.IsSpace, in s. This is a cheaper way of word counting than the obvious len(strings.Fields(s)).

func Uglify Uses

func Uglify(in string) string

Uglify does the opposite of PrettifyURLPath().

/section/name/index.html becomes /section/name.html
/section/name/           becomes /section/name.html
/section/name.html       becomes /section/name.html

func UniqueStrings Uses

func UniqueStrings(s []string) []string

UniqueStrings returns a new slice with any duplicates removed.

func WriteToDisk Uses

func WriteToDisk(inpath string, r io.Reader, fs afero.Fs) (err error)

WriteToDisk writes content to disk.

type BaseURL Uses

type BaseURL struct {
    // contains filtered or unexported fields

A BaseURL in Hugo is normally on the form scheme://path, but the form scheme: is also valid (

func (BaseURL) String Uses

func (b BaseURL) String() string

func (BaseURL) URL Uses

func (b BaseURL) URL() *url.URL

URL returns a copy of the internal URL. The copy can be safely used and modified.

func (BaseURL) WithProtocol Uses

func (b BaseURL) WithProtocol(protocol string) (string, error)

WithProtocol returns the BaseURL prefixed with the given protocol. The Protocol is normally of the form "scheme://", i.e. "webcal://".

type Blackfriday Uses

type Blackfriday struct {
    Smartypants           bool
    SmartypantsQuotesNBSP bool
    AngledQuotes          bool
    Fractions             bool
    HrefTargetBlank       bool
    SmartDashes           bool
    LatexDashes           bool
    TaskLists             bool
    PlainIDAnchors        bool
    Extensions            []string
    ExtensionsMask        []string

Blackfriday holds configuration values for Blackfriday rendering.

type ContentSpec Uses

type ContentSpec struct {
    Highlight func(code, lang, optsStr string) (string, error)
    // contains filtered or unexported fields

ContentSpec provides functionality to render markdown content.

func NewContentSpec Uses

func NewContentSpec(cfg config.Provider) (*ContentSpec, error)

NewContentSpec returns a ContentSpec initialized with the appropriate fields from the given config.Provider.

func (ContentSpec) NewBlackfriday Uses

func (c ContentSpec) NewBlackfriday() *Blackfriday

NewBlackfriday creates a new Blackfriday filled with site config or some sane defaults.

func (ContentSpec) RenderBytes Uses

func (c ContentSpec) RenderBytes(ctx *RenderingContext) []byte

RenderBytes renders a []byte.

func (*ContentSpec) TruncateWordsByRune Uses

func (c *ContentSpec) TruncateWordsByRune(words []string) (string, bool)

TruncateWordsByRune truncates words by runes.

func (*ContentSpec) TruncateWordsToWholeSentence Uses

func (c *ContentSpec) TruncateWordsToWholeSentence(s string) (string, bool)

TruncateWordsToWholeSentence takes content and truncates to whole sentence limited by max number of words. It also returns whether it is truncated.

type DistinctLogger Uses

type DistinctLogger struct {
    // contains filtered or unexported fields

DistinctLogger ignores duplicate log statements.

func NewDistinctErrorLogger Uses

func NewDistinctErrorLogger() *DistinctLogger

NewDistinctErrorLogger creates a new DistinctLogger that logs ERRORs

func NewDistinctFeedbackLogger Uses

func NewDistinctFeedbackLogger() *DistinctLogger

NewDistinctFeedbackLogger creates a new DistinctLogger that can be used to give feedback to the user while not spamming with duplicates.

func NewDistinctWarnLogger Uses

func NewDistinctWarnLogger() *DistinctLogger

NewDistinctWarnLogger creates a new DistinctLogger that logs WARNs

func (*DistinctLogger) Printf Uses

func (l *DistinctLogger) Printf(format string, v ...interface{})

Printf will log the string returned from fmt.Sprintf given the arguments, but not if it has been logged before. Note: A newline is appended.

func (*DistinctLogger) Println Uses

func (l *DistinctLogger) Println(v ...interface{})

Println will log the string returned from fmt.Sprintln given the arguments, but not if it has been logged before.

type HugoHTMLRenderer Uses

type HugoHTMLRenderer struct {
    // contains filtered or unexported fields

HugoHTMLRenderer wraps a blackfriday.Renderer, typically a blackfriday.Html Enabling Hugo to customise the rendering experience

func (*HugoHTMLRenderer) BlockCode Uses

func (r *HugoHTMLRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string)

BlockCode renders a given text as a block of code. Pygments is used if it is setup to handle code fences.

func (*HugoHTMLRenderer) List Uses

func (r *HugoHTMLRenderer) List(out *bytes.Buffer, text func() bool, flags int)

List adds task list support to the Blackfriday renderer.

func (*HugoHTMLRenderer) ListItem Uses

func (r *HugoHTMLRenderer) ListItem(out *bytes.Buffer, text []byte, flags int)

ListItem adds task list support to the Blackfriday renderer.

type HugoMmarkHTMLRenderer Uses

type HugoMmarkHTMLRenderer struct {
    Cfg config.Provider
    // contains filtered or unexported fields

HugoMmarkHTMLRenderer wraps a mmark.Renderer, typically a mmark.html, enabling Hugo to customise the rendering experience.

func (*HugoMmarkHTMLRenderer) BlockCode Uses

func (r *HugoMmarkHTMLRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string, caption []byte, subfigure bool, callouts bool)

BlockCode renders a given text as a block of code. Pygments is used if it is setup to handle code fences.

type HugoVersion Uses

type HugoVersion struct {
    // Major and minor version.
    Number float32

    // Increment this for bug releases
    PatchLevel int

    // HugoVersionSuffix is the suffix used in the Hugo version string.
    // It will be blank for release versions.
    Suffix string

HugoVersion represents the Hugo build version.

func MustParseHugoVersion Uses

func MustParseHugoVersion(s string) HugoVersion

MustParseHugoVersion parses a version string and panics if any error occurs.

func ParseHugoVersion Uses

func ParseHugoVersion(s string) (HugoVersion, error)

ParseHugoVersion parses a version string.

func (HugoVersion) Next Uses

func (v HugoVersion) Next() HugoVersion

Next returns the next Hugo release version.

func (HugoVersion) NextPatchLevel Uses

func (v HugoVersion) NextPatchLevel(level int) HugoVersion

NextPatchLevel returns the next patch/bugfix Hugo version. This will be a patch increment on the previous Hugo version.

func (HugoVersion) Prev Uses

func (v HugoVersion) Prev() HugoVersion

Prev returns the previous Hugo release version.

func (HugoVersion) ReleaseVersion Uses

func (v HugoVersion) ReleaseVersion() HugoVersion

ReleaseVersion represents the release version.

func (HugoVersion) String Uses

func (v HugoVersion) String() string

type Language Uses

type Language struct {
    Lang         string
    LanguageName string
    Title        string
    Weight       int

    Cfg config.Provider
    // contains filtered or unexported fields

Language manages specific-language configuration.

func NewDefaultLanguage Uses

func NewDefaultLanguage(cfg config.Provider) *Language

NewDefaultLanguage creates the default language for a config.Provider. If not otherwise specified the default is "en".

func NewLanguage Uses

func NewLanguage(lang string, cfg config.Provider) *Language

NewLanguage creates a new language.

func (*Language) Get Uses

func (l *Language) Get(key string) interface{}

Get returns a value associated with the key relying on specified language. Get is case-insensitive for a key.

Get returns an interface. For a specific value use one of the Get____ methods.

func (*Language) GetBool Uses

func (l *Language) GetBool(key string) bool

GetBool returns the value associated with the key as a boolean.

func (*Language) GetInt Uses

func (l *Language) GetInt(key string) int

GetInt returns the value associated with the key as an int.

func (*Language) GetLocal Uses

func (l *Language) GetLocal(key string) interface{}

GetLocal gets a configuration value set on language level. It will not fall back to any global value. It will return nil if a value with the given key cannot be found.

func (*Language) GetString Uses

func (l *Language) GetString(key string) string

GetString returns the value associated with the key as a string.

func (*Language) GetStringMap Uses

func (l *Language) GetStringMap(key string) map[string]interface{}

GetStringMap returns the value associated with the key as a map of interfaces.

func (*Language) GetStringMapString Uses

func (l *Language) GetStringMapString(key string) map[string]string

GetStringMapString returns the value associated with the key as a map of strings.

func (*Language) IsSet Uses

func (l *Language) IsSet(key string) bool

IsSet checks whether the key is set in the language or the related config store.

func (*Language) Params Uses

func (l *Language) Params() map[string]interface{}

Params retunrs language-specific params merged with the global params.

func (*Language) Set Uses

func (l *Language) Set(key string, value interface{})

Set sets the value for the key in the language's params.

func (*Language) SetParam Uses

func (l *Language) SetParam(k string, v interface{})

SetParam sets param with the given key and value. SetParam is case-insensitive.

func (*Language) String Uses

func (l *Language) String() string

type Languages Uses

type Languages []*Language

Languages is a sortable list of languages.

func NewLanguages Uses

func NewLanguages(l ...*Language) Languages

NewLanguages creates a sorted list of languages. NOTE: function is currently unused.

func (Languages) IsMultihost Uses

func (l Languages) IsMultihost() bool

IsMultihost returns whether the languages has baseURL specificed on the language level.

func (Languages) Len Uses

func (l Languages) Len() int

func (Languages) Less Uses

func (l Languages) Less(i, j int) bool

func (Languages) Swap Uses

func (l Languages) Swap(i, j int)

type PathSpec Uses

type PathSpec struct {

    // The file systems to use
    Fs  *hugofs.Fs

    // The config provider to use
    Cfg config.Provider
    // contains filtered or unexported fields

PathSpec holds methods that decides how paths in URLs and files in Hugo should look like.

func NewPathSpec Uses

func NewPathSpec(fs *hugofs.Fs, cfg config.Provider) (*PathSpec, error)

NewPathSpec creats a new PathSpec from the given filesystems and Language.

func (*PathSpec) AbsPathify Uses

func (p *PathSpec) AbsPathify(inPath string) string

AbsPathify creates an absolute path if given a relative path. If already absolute, the path is just cleaned.

func (*PathSpec) AbsURL Uses

func (p *PathSpec) AbsURL(in string, addLanguage bool) string

AbsURL creates an absolute URL from the relative path given and the BaseURL set in config.

func (*PathSpec) GetLayoutDirPath Uses

func (p *PathSpec) GetLayoutDirPath() string

GetLayoutDirPath returns the absolute path to the layout file dir for the current Hugo project.

func (*PathSpec) GetRelativeThemeDir Uses

func (p *PathSpec) GetRelativeThemeDir() string

GetRelativeThemeDir gets the relative root directory of the current theme, if there is one. If there is no theme, returns the empty string.

func (*PathSpec) GetThemeDataDirPath Uses

func (p *PathSpec) GetThemeDataDirPath() (string, error)

GetThemeDataDirPath returns the theme's data dir path if theme is set. If theme is set and the data dir doesn't exist, an error is returned.

func (*PathSpec) GetThemeDir Uses

func (p *PathSpec) GetThemeDir() string

GetThemeDir gets the root directory of the current theme, if there is one. If there is no theme, returns the empty string.

func (*PathSpec) GetThemeI18nDirPath Uses

func (p *PathSpec) GetThemeI18nDirPath() (string, error)

GetThemeI18nDirPath returns the theme's i18n dir path if theme is set. If theme is set and the i18n dir doesn't exist, an error is returned.

func (*PathSpec) GetThemeStaticDirPath Uses

func (p *PathSpec) GetThemeStaticDirPath() (string, error)

GetThemeStaticDirPath returns the theme's static dir path if theme is set. If theme is set and the static dir doesn't exist, an error is returned.

func (*PathSpec) GetThemesDirPath Uses

func (p *PathSpec) GetThemesDirPath() string

GetThemesDirPath gets the static files directory of the current theme, if there is one. Ignores underlying errors. TODO(bep) Candidate for deprecation?

func (*PathSpec) LayoutDir Uses

func (p *PathSpec) LayoutDir() string

LayoutDir returns the relative layout dir in the current configuration.

func (*PathSpec) MakePath Uses

func (p *PathSpec) MakePath(s string) string

MakePath takes a string with any characters and replace it so the string could be used in a path. It does so by creating a Unicode-sanitized string, with the spaces replaced, whilst preserving the original casing of the string. E.g. Social Media -> Social-Media

func (*PathSpec) MakePathSanitized Uses

func (p *PathSpec) MakePathSanitized(s string) string

MakePathSanitized creates a Unicode-sanitized string, with the spaces replaced

func (*PathSpec) PaginatePath Uses

func (p *PathSpec) PaginatePath() string

PaginatePath returns the configured root path used for paginator pages.

func (*PathSpec) PrependBasePath Uses

func (p *PathSpec) PrependBasePath(rel string) string

PrependBasePath prepends any baseURL sub-folder to the given resource if canonifyURLs is disabled. If canonifyURLs is set, we will globally prepend the absURL with any sub-folder, so avoid doing anything here to avoid getting double paths.

func (*PathSpec) RelURL Uses

func (p *PathSpec) RelURL(in string, addLanguage bool) string

RelURL creates a URL relative to the BaseURL root. Note: The result URL will not include the context root if canonifyURLs is enabled.

func (*PathSpec) StaticDirs Uses

func (p *PathSpec) StaticDirs() []string

StaticDirs returns the relative static dirs for the current configuration.

func (PathSpec) String Uses

func (p PathSpec) String() string

func (*PathSpec) Theme Uses

func (p *PathSpec) Theme() string

Theme returns the theme name if set.

func (*PathSpec) ThemeSet Uses

func (p *PathSpec) ThemeSet() bool

ThemeSet checks whether a theme is in use or not.

func (*PathSpec) ThemesDir Uses

func (p *PathSpec) ThemesDir() string

Theme returns the theme relative theme dir.

func (*PathSpec) URLEscape Uses

func (p *PathSpec) URLEscape(uri string) string

URLEscape escapes unicode letters.

func (*PathSpec) URLPrep Uses

func (p *PathSpec) URLPrep(in string) string

URLPrep applies misc sanitation to the given URL.

func (*PathSpec) URLize Uses

func (p *PathSpec) URLize(uri string) string

URLize is similar to MakePath, but with Unicode handling Example:

uri: Vim (text editor)
urlize: vim-text-editor

func (*PathSpec) URLizeAndPrep Uses

func (p *PathSpec) URLizeAndPrep(in string) string

URLizeAndPrep applies misc sanitation to the given URL to get it in line with the Hugo standard.

func (*PathSpec) URLizeFilename Uses

func (p *PathSpec) URLizeFilename(filename string) string

URLizeFilename creates an URL from a filename by esacaping unicode letters and turn any filepath separator into forward slashes.

func (*PathSpec) UnicodeSanitize Uses

func (p *PathSpec) UnicodeSanitize(s string) string

UnicodeSanitize sanitizes string to be used in Hugo URL's, allowing only a predefined set of special Unicode characters. If RemovePathAccents configuration flag is enabled, Uniccode accents are also removed.

func (*PathSpec) WorkingDir Uses

func (p *PathSpec) WorkingDir() string

WorkingDir returns the configured workingDir.

type RenderingContext Uses

type RenderingContext struct {
    Content      []byte
    PageFmt      string
    DocumentID   string
    DocumentName string
    Config       *Blackfriday
    RenderTOC    bool
    Cfg          config.Provider

RenderingContext holds contextual information, like content and configuration, for a given content rendering. By creating you must set the Config, otherwise it will panic.

Package helpers imports 44 packages (graph) and is imported by 93 packages. Updated 2017-11-19. Refresh now. Tools for package owners.