package source

import "github.com/gohugoio/hugo/source"

Package source contains the types and functions related to source files.

Index

Types

type File

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

File describes a source file.

func NewContentFileInfoFrom

func NewContentFileInfoFrom(path, filename string) *File

Used in tests.

func NewFileInfo

func NewFileInfo(fi hugofs.FileMetaInfo) *File

func (*File) BaseFileName

func (fi *File) BaseFileName() string

BaseFileName returns a file's name without extension (e.g. "page.sv").

func (*File) ContentBaseName

func (fi *File) ContentBaseName() string

ContentBaseName is a either TranslationBaseName or name of containing folder if file is a bundle.

func (*File) Dir

func (fi *File) Dir() string

Dir gets the name of the directory that contains this file. The directory is relative to the content root.

func (*File) Ext

func (fi *File) Ext() string

Ext returns a file's extension without the leading period (e.g. "md").

func (*File) FileInfo

func (fi *File) FileInfo() hugofs.FileMetaInfo

FileInfo returns a file's underlying os.FileInfo.

func (*File) Filename

func (fi *File) Filename() string

Filename returns a file's absolute path and filename on disk.

func (*File) IsContentAdapter

func (fi *File) IsContentAdapter() bool

IsContentAdapter returns whether the file represents a content adapter. This means that there may be more than one Page associated with this file.

func (*File) IsZero

func (fi *File) IsZero() bool

func (*File) Lang

func (fi *File) Lang() string

Lang returns a file's language (e.g. "sv"). Deprecated: Use .Page.Language.Lang instead.

func (*File) LogicalName

func (fi *File) LogicalName() string

LogicalName returns a file's name and extension (e.g. "page.sv.md").

func (*File) Open

func (fi *File) Open() (hugio.ReadSeekCloser, error)

Open implements ReadableFile.

func (*File) Path

func (fi *File) Path() string

Path gets the relative path including file name and extension. The directory is relative to the content root.

func (*File) Section

func (fi *File) Section() string

Section returns a file's section.

func (*File) String

func (fi *File) String() string

func (*File) TranslationBaseName

func (fi *File) TranslationBaseName() string

TranslationBaseName returns a file's translation base name without the language segment (e.g. "page").

func (*File) UniqueID

func (fi *File) UniqueID() string

UniqueID returns a file's unique, MD5 hash identifier.

type GitInfo

type GitInfo = gitmap.GitInfo

GitInfo provides information about a version controlled source file.

type SourceSpec

type SourceSpec struct {
	*helpers.PathSpec

	SourceFs afero.Fs
	// contains filtered or unexported fields
}

SourceSpec abstracts language-specific file creation. TODO(bep) rename to Spec

func NewSourceSpec

func NewSourceSpec(ps *helpers.PathSpec, inclusionFilter *glob.FilenameFilter, fs afero.Fs) *SourceSpec

NewSourceSpec initializes SourceSpec using languages the given filesystem and PathSpec.

func (*SourceSpec) IgnoreFile

func (s *SourceSpec) IgnoreFile(filename string) bool

IgnoreFile returns whether a given file should be ignored.

Source Files

fileInfo.go sourceSpec.go

Version
v0.148.1 (latest)
Published
Jul 11, 2025
Platform
linux/amd64
Imports
13 packages
Last checked
2 days ago

Tools for package owners.