Creating a PocketPages Page
PocketPages allows you to create dynamic pages for your application using EJS templating. Below are the steps and guidelines to create a page that will be served by PocketPages.
Creating Pages
- Create an EJS File: Inside the
pb_hooks/pages/
directory, create an.ejs
file. This file will represent the page that you want to serve.
For example, to create an "About" page:
pb_hooks/pages/about.ejs
- Special Case -
index.ejs
: Theindex.ejs
file has a special role at any directory level.
At the root level:
pb_hooks/pages/index.ejs -> serves "/"
In subdirectories:
pb_hooks/pages/products/index.ejs -> serves "/products"
- Serving Pages: Any
.ejs
file withinpb_hooks/pages/
can be served directly. The name of the file (minus the.ejs
extension) will correspond to the URL path.
Example file structure:
pb_hooks/pages/
├── index.ejs -> "/"
├── about.ejs -> "/about"
├── contact.ejs -> "/contact"
└── products/
├── index.ejs -> "/products"
└── details.ejs -> "/products/details"
- Nested Pages: You can organize your pages into subdirectories. The routing will follow the directory structure. If no specific file matches the route, an
index.ejs
in the corresponding directory will be served.
Example routing table:
URL Path File Path
/ pb_hooks/pages/index.ejs
/about pb_hooks/pages/about.ejs
/contact pb_hooks/pages/contact.ejs
/products pb_hooks/pages/products/index.ejs
/products/details pb_hooks/pages/products/details.ejs