Fork me on GitHub


Razor and Markdown static site generator


Ocam pages may be written in several formats. In addition to vanilla HTML, files may be written in C# Razor and Markdown. Any files that are not in one of these formats are copied to the Html output directory verbatim. This behavior makes it easy to structure your site any way you like, including having separate image, script, and style directories.


Any content that is not a Razor or Markdown file is copied verbatim to the output Html directory.


Any .cshtml files under the Site directory will be loaded and executed during the build process. Their contents will be rendered to the Html directory.

The backing class for these pages is the PageTemplate<> class and the model is PageModel.

   Layout = "Main";
   ViewBag.Title = "Home";




Any files with the extension .markdown or .md will be processed as Markdown and the result will be stored under the Html directory.

Ocam processes the result of the Markdown transformation as Razor. This only works to a limited degree due to differences in syntax. In particular, variables and model properties work, while block-level constructs generally don't.

Ocam Markdown files support a front matter section in the style of Jekyll, which is delimted by --- markers. This section is parsed as C# as if it were in a @{ ... } code block at the head of a Razor file.

Here is the equivalent of the above page in Ocam flavored Markdown.

Layout = "Main";
ViewBag.Title = "Home";



Note that you must excape the @ symbol with a double @@ symbol if you want it to appear in the rendered output. This is required because Markdown files are postprocessed as Razor files. The @ symbol is interpreted as the begining of a Razor expression, which allows you to to reference Model properties or invoke helpers, such as @Link().

This requirement does not exist for code blocks. The @ symbol in a code block is automatically escaped, making it easier to paste C# code into a Markdown file.


There are several template flavors: layouts, includes, and templates. Generic templates are experimental and won't be covered here.


A layout file is much like it's cousin in ASP.NET MVC. It is used to define the structure of an HTML file that can be shared between pages. The only requirement is that @RenderBody() be called somewhere in the file.

    <link rel="stylesheet" href="@Href("~/styles/main.css")" />


Includes are pieces of code or markup that can be reused from other content or layout files.

        <li><a href="@Link("")">Home</a></li>
        <li><a href="@Link("")">About</a></li>

To reference an include, use the Include method:


Includes are similar to MVC partials.