About Documentation Github

Getting Started

This guide will show you how to use the Pagenode library and how to get something on the screen quickly.

  1. Download the latest pagenode.php
  2. Create a directory called nodes/ next to it
  3. Create nodes/ with some Markdown content
  4. Create an index.php with the following content:

route('/', function() {
    $node = select('nodes/')->one(['keyword' => 'hello']);


This will set up a handler for the route "/", which will look for a file called in the nodes/ directory.

In Pagenode, a keyword is the file name minus the .md extension. By definition, a keyword is unique – you can't have two files with the same name.

After the node has been loaded, the route handler will include our template templates/node.html.php, so let's create it:

<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
    <title><?= $node->title ?? 'Pagenode' ?></title>

    <?= $node->body ?>

    <p class="foot">
        Created at <?= $node->date->format('Y.m.d') ?>

You can now start PHPs built-in Web Server to have a quick look at your page. Issue the following command in the directory where your index.php is located:

php -S localhost:8080

You should now be able to load localhost:8080 in your browser and read your file.

Setup for Apache and Nginx

In order to make the URL routing work with clean URLs, you have to let your index.php handle all requests.

For Apache, you can place Pagenode's .htacces file in the directory where your index.php is located.

For Nginx you can use the following configuration for your host:

server {
    root /var/www/yourdomain;

    location ~ /\.git {
        deny all;

    include php-fastcgi.conf;

    # Let Pagenode handle all requests
    try_files $uri $uri/ /index.php?$query_string;

If you don't want to setup clean URLs, you can also route requests via a GET parameter.

E.g. for URLs like you can change the dispatch() call to use the path GET parameter:


Or, a bit cleaner, for URLs like use the first $_GET key:


Up Next: Adding Content »

© 2024 Dominic Szablewski – rendered in (2.66ms)