Skip to content

Objects

ReFreezed edited this page May 2, 2021 · 14 revisions

These are global objects.


site

These values can be configured in config.lua.

site.baseUrl

The base part of the website's URL, e.g. "http://www.example.com/".

site.defaultLayout

The default layout pages will use. The default value is "page" (which corresponds to the file layouts/page.html). Setting this to an empty string will make pages use no layout by default.

site.languageCode

The code for the language of the website, e.g. "dk". (This doesn't do much yet, but will be used for i18n in the future.)

site.title

The title of the website.

page

page.aliases

A list of URLs that point to previous locations of the current page. This serves the same purpose as config.redirections. Example:

{{
-- Current file: a-better-omelet.md
page.title   = "Making a Better Omelet"
page.aliases = {"/how-to-make-omelet/", "/omelet-tutorial/"}
}}

page.content

The HTML contents of the current page. Available in layouts. Example:

<!-- layouts/page.html -->
<html>
	<head>
		<title>{{ page.title }}</title>
	</head>
	<body>
		{{ page.content }}
	</body>
</html>

page.date

What date the page was created. See datetime for the date format. Also see page.publishDate.

page.isDraft

If the current page is a draft. Drafts are excluded from the building process (unless the --drafts option is used).

page.isHome

If the current page is the root index page, aka the homepage.

page.isIndex

If the current page is an index page.

page.isPage

If the current page is in fact a page. This value is true for HTML/Markdown files, and false for CSS files for example.

page.isSpecial

If the current page is some kind of special page. Special pages are ignored by subpages(). Set this to true for e.g. 404 error pages.

page.layout

What layout the page should use. The default is the value of site.defaultLayout. Setting this to an empty string will make the page not use any layout.

page.params

Table for storing any custom data you want. Also see the params/P aliases.

page.permalink

The permanent URL for the current page. This URL is absolute.

page.publishDate

What date the page is published. If the date is in the future then the page is excluded from the build process. The default value is the value of page.date. See datetime for the date format.

page.redirectionTarget

On redirection pages, this value is set to the redirection target URL. Otherwise, it's empty.

page.title

The title of the current page. Every page should update this value.

page.url

The relative URL to the current page on the site.

Other Objects

data

Access data from the data folder. Type e.g. data.cats to retrieve the contents of data/cats.lua or data/cats.toml. See DATA_FILE_EXTENSIONS for supported data formats.

params

params or P

Table for storing any custom data you want. Aliases for page.params.

Clone this wiki locally