Order of operations
What does Lume do to build your site?
This is a high-level description of how Lume builds your site. When you run lume
, the following operations are executed in this order:
- Dispatch the
beforeBuild
event. - Ensure the
dest
folder is empty (unlessemptyDest
is disabled). - Walk the
src
folder recursively and build a tree with all files and folders. Any remote files are added here. - Dispatch the
afterLoad
event. - Walk the tree recursively and load all files matching with a valid file extension, like
.md
,.vto
, etc.- Skip files and folders starting with
_
,.
, or ignored withsite.ignore()
. - If the file must be copied statically, calculate the source and destination paths.
- If the name of the file is
_data
or is inside a_data
folder, it is shared data. - If the file is inside a
_components
folder, it is a component. - If it has a known extension, it's a page.
- Otherwise, ignore it (or copy it if
copyRemainingFiles
is enabled).
- Skip files and folders starting with
- Dispatch the
beforeRender
event. - Group all pages by
renderOrder
value and sort them. - For each group of pages with the same
renderOrder
:- If the page content is a generator, generate all the sub-pages.
- Calculate the final url.
- Run registered preprocessors.
- Render the page using the assigned template engine and layout.
- Dispatch the
afterRender
event. - Run registered processors.
- Dispatch the
beforeSave
event. - Save all pages to the
dest
folder. - Dispatch the
afterBuild
event.
Watch mode
In watch mode (with lume --serve
or lume --watch
), the first build is exactly the same, but any following changes have some differences:
- The
dest
folder is not emptied. - Only files with changes are reloaded.
- Steps 4 to 10 are exactly the same. All pages (not just the modified ones) are re-rendered, because a change in one file can affect many pages, so we have to render all pages again. See scoped updates to learn how to configure this.
- All pages that have changed are saved to
dest
.