-
Notifications
You must be signed in to change notification settings - Fork 3
Site Configuration
Site-specific configurations are stored in config.lua in the site root. The file is expected to return a table with any of these fields:
title -- See site.title
baseUrl -- See site.baseUrl
languageCode -- See site.languageCode
defaultLayout -- See site.defaultLayout
redirections -- Table with source URLs as keys and target URLs are values.
ignoreFiles -- Array of filename patterns to exclude from site generation.
ignoreFolders -- Array of folder name patterns to exclude from site generation.
processors -- Table with file content processors.
rewriteOutputPath -- See below.
rewriteExcludes -- See below.
before -- Function that is called before site generation.
after -- Function that is called after main site generation.
validate -- Function that is called after all tasks are done.
htaccess = { -- Table with special .htaccess file settings. (Apache server)
redirect -- Flag for using mod_rewrite to redirect URLs.
}All fields are optional.
Table of URL redirections, with source URLs as keys and target URLs are values. Example:
config.redirections = {
["/old-post/"] = "/new-post/",
["/duck/"] = "https://duckduckgo.com/",
}Also see page.aliases for page-level redirections (which work the same way), and htaccess.redirect if you're on an Apache server.
Note: Queries are not yet supported for the source URLs.
Use this to control where files are written inside the output folder.
Note that URLs don't change.
Example usage of rewriteOutputPath is to use it together with URL rewriting on the server.
Most people should ignore this configuration entirely.
If the value is a string then it's used as format for the path. Example:
config.rewriteOutputPath = "/subfolder%s" -- %s is the original path.
-- "content/index.html" is written to "output/subfolder/index.html"
-- "content/blog/post.md" is written to "output/subfolder/blog/post/index.html"
-- etc.If the value is a function then the function is expected to return the rewritten path. Example:
config.rewriteOutputPath = function(path)
-- Put .css and .js files in a subfolder.
if isAny(getExtension(path), {"css","js"}) then
return "/subfolder"..path
end
return path
endThe default value for rewriteOutputPath is "%s"
This is an array of path patterns for files that should not be rewritten by rewriteOutputPath. Example:
-- Exclude topmost .htaccess file.
config.rewriteExcludes = {"^/%.htaccess$"}If set, then rewrite directives are written into a .htaccess file at the top of the output folder for all page aliases and redirections. If the file already exists then the directives are inserted at the end of the file. To control where the directives are inserted, add the following to the line where they should be inserted:
# :webgen.redirections:
- Home
- Command Line
- Site Configuration
- Embedding Lua
- Constants
- Functions
- Objects
- Other Modules and Information