Content files contain the pages of your site and are processed based on their media type (which is determined by file extension).

The following extensions are recognized by default:

  • .html processes the file as plain HTML.
  • .md processes the file as Markdown.
  • .cshtml processes the file as Razor.

The ContentFiles setting controls how content files are located and is set to **/{!_,}*.{html,cshtml,md} by default. This loads all .html, .cshtml, and .md files in any input directory unless it starts with an underscore _.

In all cases, global processing (such as processing front matter and applying shortcodes) is performed and layouts and themes are applied.

Many themes treat content differently depending on what sub-folder the files are in. For example, themes for blogging often infer blog posts should go in a "input/posts" sub-folder. In most cases the specific paths used for different types of content are configurable as settings.

Accessing Content Files

Content files are processed by the Content pipeline and can be accessed through the Outputs property of the execution context (which is also available directly in some templating languages like Razor as an Outputs property).

The resulting content documents are output from the pipeline in a hierarchy, so only documents representing top-level folders are returned from the Outputs collection. To flatten the documents and filter for a set of ones you want you'll need to call .Flatten() first. You can also use .FilterSources() and .FilterDestinations() extension methods to filter the collection of output documents using a globbing pattern.

For example, the following code will find all content documents that describe different fruits stored in a food/fruit folder under the default input folder:

IDocument[] fruits = Outputs["Data"]
  .FilterSources("food/fruit/*")
  .ToArray();

Preventing Content File Output

By default content files are output to their destination path. You may want to adjust this behavior for individual content files or entire directories. This behavior can be controlled with the ShouldOutput metadata and there are a few ways to set it:

  • Set ShouldOutput to false directly in the data file which will prevent that file from being output.
  • Set ShouldOutput to false for an individual file, and entire directory, or an entire directory tree in a directory metadata file.
  • Set ShouldOutput to false in a sidecar file.
  • Set ShouldOutput to false in front matter.

Preventing content file output can be helpful when you want to define partial content (like product descriptions, personal biographies, etc.) for inclusion in other documents without resulting in an output file.

Child Pages

Content Hierarchy

Documents from the Content pipeline are structured in a hierarchy that makes it easy to navigate them similar to their location on disk.

Excerpts And Headings

Statiq Web attempts to extract an excerpt and headings from your content and stores them in metadata.

Links And Cross References

Statiq Web provides a number of ways to link to documents.

Redirects

Statiq can generate redirects for your content if it changes location.

Resource Mirroring

Statiq Web can locally mirror remote resources such as scripts and stylesheet links.

Shortcodes

Shortcodes are small but powerful macros that can generate content or add metadata to your documents.