hugo: Index | Files

package create

import ""

Package create provides functions to create new content.


Package Files

content.go content_template_handler.go


const (
    // ArchetypeTemplateTemplate is used as initial template when adding an archetype template.
    ArchetypeTemplateTemplate = `---
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
draft: true


func NewContent Uses

func NewContent(
    sites *hugolib.HugoSites, kind, targetPath string) error

NewContent creates a new content file in the content directory based upon the given kind, which is used to lookup an archetype.

type ArchetypeFileData Uses

type ArchetypeFileData struct {
    // The archetype content type, either given as --kind option or extracted
    // from the target path's section, i.e. "blog/" will resolve to
    // "blog".
    Type string

    // The current date and time as a RFC3339 formatted string, suitable for use in front matter.
    Date string

    // The Site, fully equipped with all the pages etc. Note: This will only be set if it is actually
    // used in the archetype template. Also, if this is a multilingual setup,
    // this site is the site that best matches the target content file, based
    // on the presence of language code in the filename.
    Site *hugolib.SiteInfo

    // Name will in most cases be the same as TranslationBaseName, e.g. "my-post".
    // But if that value is "index" (bundles), the Name is instead the owning folder.
    // This is the value you in most cases would want to use to construct the title in your
    // archetype template.
    Name string

    // The target content file. Note that the .Content will be empty, as that
    // has not been created yet.

ArchetypeFileData represents the data available to an archetype template.

Package create imports 17 packages (graph) and is imported by 42 packages. Updated 2020-02-18. Refresh now. Tools for package owners.