Objects - ReFreezed/LuaWebGen GitHub Wiki
Note: The documentation has moved to the LuaWebGen website. Information here may be out of date!
These are global objects.
These values can be configured in config.lua.
The base part of the website's URL, e.g. "http://www.example.com/"
.
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.
A description for the website.
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.)
The title of the website.
Note that all fields become read-only after the page content has been generated (or after lock() has been called).
- page.aliases
- page.content
- page.date
- page.dateModified
- page.description
- page.isDraft
- page.isHome
- page.isIndex
- page.isPage
- page.isSpecial
- page.layout
- page.params
- page.permalink
- page.publishDate
- page.redirectionTarget
- page.title
- page.url
A list of URLs that point to previous locations of the 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/"}
}}
[readonly] The HTML content of the page. Available in layouts (and later). Trying to access the content before it has finished generating or in an invalid situation will raise an error. Example:
<!-- layouts/page.html -->
<html>
<head>
<title>{{ page.title }}</title>
</head>
<body>
{{ page.content }}
</body>
</html>
What date the page was created. Even though the default value is the time the file was last modified (if that information is accessible by the program) it's still recommended that every page update this to an explicit value (otherwise the date may end up being 1970-01-01). See datetime for the date format. Also see page.publishDate and page.dateModified.
Note: Every page generated with generateFromTemplate() should update this value because there's no source file to grab the modified time from.
[v1.3] What date the page was last modified. If this isn't set then the value of page.date is used. See datetime for the date format.
A description for the page.
If the page is a draft. Drafts are excluded from the website build (unless the --drafts option is used).
[readonly] If the page is the root index page, aka the homepage.
[readonly] If the page is an index page.
[readonly] If the page is in fact a page. This value is true for HTML/Markdown files, and false for CSS files for example.
If the page is some kind of special page. Special pages are ignored by subpages(). Set this to true for e.g. 404 error pages.
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.
[readonly] Table for storing any custom data you want. Also see the params/P aliases. Note that while the table itself cannot be swapped out, fields of the table can be updated freely.
[readonly] The permanent URL for the page. This URL is absolute.
What date the page was, or is going to be, published. If the date is in the future (or past the date specified by the --date option) then the page is excluded from the website build. If this isn't set then the value of page.date is used. See datetime for the date format.
[readonly] On redirection pages, this value is set to the redirection target URL. Otherwise, it's empty.
The title of the page. Every page should update this value.
[readonly] The relative URL to the page on the site.
Note: If site.baseUrl has a path containing a subdirectory then this URL is relative to that directory and not to the host name. For example, if
site.baseUrl
is"http://example.com/abc/"
thenpage.url
for the filecontent/foo.md
will be"/foo/"
and page.permalink will be"http://example.com/abc/foo/"
. Or, in other words,page.url
for a file will always be the same no matter whatsite.baseUrl
is. Use url() to safely link to a page usingpage.url
.
Access data from the data folder.
Type e.g. data.cats
to retrieve the contents of data/cats.lua
or data/cats.toml
.
Files can be in subfolders (e.g. type data.foo.bar
to access data/foo/bar.toml
).
See DATA_FILE_EXTENSIONS for supported data formats.
params
or P
Table for storing any custom data you want. Aliases for page.params.
[v1.3]
Access scripts from the scripts folder.
Type e.g. scripts.foo()
to call the function returned by of scripts/foo.lua
.
Files can be in subfolders (e.g. type scripts.abc.xyz
to access scripts/abc/xyz.lua
).
Note that scripts can be accessed with or without the prefix scripts.
- this object mostly exists in case there's a name conflict between a script and one of LuaWebGen's existing globals.