Pages
To create pages you must first specify in which directory relative to the server you will be placing your HTML pages when setting up the engine.
const {engine} = require('@beforesemicolon/html-plus');
const app = express();
engine(app, path.resolve(__dirname, './pages'));
Once you have your pages directory, which you can name anything you want, you can start creating HTML files which will be used as pages.
As mentioned in before, the way you structure your pages directory files is how the routes will be set. There are a few things you should know when doing so:
- index.html corresponds to "/" path or the path of the directory it is placed inside. Placing index.html at the root pages directory will match path "/" and placing it in, for example, projects directory will match "/projects" path.
- Any html file name that starts with "underscore" will be interpreted as a partial file. No path will match such files. Use this rule to create partials that you can include in your page files.
- By default, "/404" will have a default minimal page. You can override this by simply creating a 404.html file at the root pages directory.
- Any html file inside the pages directory will override express custom routes your create.
- Every file will match a single route and can only be reused in custom express route you setup.