中文 | ENGLISH

OpooPress

A java based static website generator.

Front-matter

Ver: 1.x

Any file that contains a YAML front matter block will be processed by OpooPress as a special file, we called blog source file. The front matter must be the first thing in the file and must take the form of valid YAML set between triple-dashed lines. Here is a basic example:

 ---
 layout: post
 title: 'OpooPress 1.0.0 has been released'
 date: '2013-08-08 00:30'
 comments: true
 categories: ['opoopress']
 url: '/article/opoopress-1.0.0-has-been-released/'
 ---

Between these triple-dashed lines, you can set predefined variables (see below for a reference) or even create custom ones of your own. These variables will then be available to you to access using FreeMarker tags in the source file of pages or posts.

1. Public Variables

Public variables that you can set in the front-matter of a page or post.

Variable Description

layout

The layout of current file. OpooPress defined three default layouts: default, post, page, template file has suffix _<layout>.ftl.

title

The title of page or post.

date

Creation or published time. This variable is required in a post.

date_format

The time format of date variable. Optional. See Java DateFormat.

updated

The update time. Optional.

updated_format

The time format of updated variable. Optional. See Java DateFormat.

path

The relative path to source directory of the source file. e.g. /docs/frontmatter.markdown.

url

The final URL of page or post. Optional.

comments

Current page / post whether to allow comments. Optional. default is true.

sidebar

Current page / post whether to allow side bar. Optional. default is true.

footer

Current page / post whether to contain footer. Optional. default is true.

author

Author of this page or post. Optional.

keywords

Keywords. Optional. It will be used as <meta name="keywords" content="keywords"> in the output HTML file.

desription

Desription. Optional. It will be used as <meta name="desription" content="desription"> in the output HTML file.

2. Variables for Post Only

Variable Description

published

Not draft. Default value is true.

category

categories

Category array. category specify single category, e.g. category: Blog. categories specify a category array, e.g. categories: [Java, Maven, XXX]. OpooPress supports tree category structure.

tag

tags

Tag. tag specify single tag, e.g. tag: Tag0. tags specify a tag array, e.g. tags: [Tag1, Tag2, Tag3]

excerpt

The excerpt of post. Optional. Show post excerpt and read on button in blog index page.

3. Custom Front-matter Variables

Any variables in the front matter that are not predefined are mixed into the data that is sent to the FreeMarker templating engine during the conversion. For instance, if you set var1 and var2, you can use that in your layout or other source file:

--- 
var1: "var1"
var2: "a b c"
...
--- 

The value of variable `var1` in this page is ${page.var1}.
The value of variable `var2` in this page is /${page.var2}/.
The url of this site is ${site.url}

output

The value of variable `var1` in this page is var1.
The value of variable `var2` in this page is /a b c/.
The url of this site is http://www.opoopress.com.

Also see Jekyll Front-matter for more.

Comments