Content And Data

Statiq Web has a variety of ways of reading, writing, and working with different kinds of files.

There are three broad categories of files in Statiq Web:

  • Assets which are either copied to the output folder directly or transformed during copying. Examples include images, standalone JavaScript, CSS stylesheets, and Less or Sass files.
  • Content which typically output as HTML files, directly or after one or more templates are applied. Examples include Markdown, Razor, and HTML files.
  • Data which may or may not be output and can be used when applying a template to content files. Examples include JSON, YAML, and XML files.

Files should be placed in the input folder (or a sub-folder) and the InputFiles setting controls what files from the input folder are loaded. It's set to **/{!_,}* by default which loads all files in any input directory unless it starts with an underscore _.

The category of a file, and thus what operations are performed on it, is determined by its media type (which is inferred from its file extension). Unless the file extension is recognized as a content or data file such as Markdown, Razor, JSON, or YAML, the file is considered an asset file. The category can be changed by setting ContentType for the document. For example, you can treat a JSON file which would normally be interpreted as a data file and processed as JSON as an asset file that should be copied to the output folder directly by setting ContentType to Asset via something like a sidecar file.

Within a given category, the media type of a file determines what templates and other processing will be performed on the file. The media type is typically determined by file extension, but you can also change the media type of a file by changing the MediaType setting. This can often be useful in combination with the ContentType setting. For example, if you have a JSON file that you want to treat as data but it has a .css extension for some reason, set ContentType to Data and MediaType to application/json. This will treat the file as if it had a .json extension in the first place.

You can also change the ContentType and MediaType for entire directories using directory metadata. For example, if your input folder contains a subfolder like node_modules that you want to copy wholesale to the output folder, but some of the files contained within the node_modules folder would be processed by either asset, content, or data templates, you can essentially treat every file as if it were a text file to be copied directly to the output folder by creating a _directory.yaml file inside your node_modules folder with the following content:

ContentType: Asset
MediaType: text/plain

Both content files and data files support functionality like directory metadata files, sidecar files, and front matter. The main difference is that templates like Markdown and Razor are processed for content files whereas data files are parsed as data formats like JSON and YAML and add to the metadata of a document.

Features like archives and feeds also let you work with content and data and produce different kinds of outputs from them.

Child Pages

Assets

Asset files are either copied directly to the output folder or, if the file type is known to require processing like Less or Sass files, transformed and then copied to output.

Content

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

Data

In addition to content, Statiq Web has rich support for data files.

Metadata

Metadata lets you add bits of information to documents and control their behavior.

Scripts

Files with a .csx or .cs extension are processed as a script. Similar to computed values, full scripts also provide access to a number of predefined global properties (see the ScriptBase class in Statiq.Core for all script properties):

Document Hierarchy

The structuring of documents in a hierarchy is an important concept to understand since it helps navigate documents to create components like breadcrumbs or navigation bars.

Enumerating Values

Statiq Web has a nifty feature where you can declare a sequence of values to be enumerated within the front matter of a file and it will create additional documents for each of the values.

Archives

Archives are one of the most powerful features of Statiq Web and allow you to group and page content.

Feeds

Feed files let you define RSS, Atom, and/or RDF feeds for any content or data in your site.

Excluding Documents

Documents can be easily excluded from generation, either by removing them entirely or by suppressing their output (but still processing them in the appropriate pipeline).

Templates

Statiq Web supports multiple template languages and you can specify which ones should be applied for your site. The specification of a template language, to what files it should apply, and when it should be executed is generally referred to as a template.