Edit this file to change the error-message which is shown if a page is not found.
-## Meta information
-Each Markdown page can include optional meta information using HTML comments at the top of the file.
+## Metadata
+Each Markdown page can include optional meta information at the top of the file (Format: YAML Font Matter).
These values will be automatically extracted and used in the <head> section of the generated HTML page.
Example Markdown file (about.md) with meta information:
- <!-- title: About Us -->
- <!-- description: Learn more about our mission and team. -->
- <!-- robots: index, follow -->
+ ---
+ title: About Us
+ description: Learn more about our mission and team.
+ robots: index, follow
+ ---
# Welcome to Our Company
// Read the content of the requested Markdown file into a string
$markdown = file_get_contents($file);
- // Set defaults for Titel and meta-values
- $defaultPageTitle = ucfirst($page);
- $defaultMetaDescription = "";
- $defaultMetaRobots = "index, follow";
+ // Set defaults for page-titel and meta-values
+ $pageTitle = ucfirst($page);
+ $metaDescription = "";
+ $metaRobots = "index, follow";
- // Overwrite defaults by extracting individual title, description and robots from the first lines of the markdown file
- $pageTitle = $defaultPageTitle;
- $metaDescription = $defaultMetaDescription;
- $metaRobots = $defaultMetaRobots;
- if (preg_match('/^<!--\s*title:(.*?)\s*-->$/m', $markdown, $matches)) {
- $pageTitle = trim($matches[1]);
- }
- if (preg_match('/^<!--\s*description:(.*?)\s*-->$/m', $markdown, $matches)) {
- $metaDescription = trim($matches[1]);
- }
- if (preg_match('/^<!--\s*robots:(.*?)\s*-->$/m', $markdown, $matches)) {
- $metaRobots = trim($matches[1]);
+ // Detect and extract YAML Front Matter
+ if (preg_match('/^---\s*(.*?)\s*---\s*(.*)$/s', $markdown, $matches)) {
+ $yaml = $matches[1];
+ $markdown = $matches[2]; // Markdown content without front matter
+
+ // Parse YAML (basic parser without dependencies)
+ foreach (explode("\n", $yaml) as $line) {
+ if (preg_match('/^\s*(title|description|robots):\s*(.*)$/', $line, $meta)) {
+ $key = trim($meta[1]);
+ $value = trim($meta[2]);
+ if ($key === 'title') $pageTitle = $value;
+ if ($key === 'description') $metaDescription = $value;
+ if ($key === 'robots') $metaRobots = $value;
+ }
+ }
}
// Load header and footer markdown files and convert to HTML
-<!-- title: 404 Error -->
-<!-- robots: noindex, nofollow -->
+---
+title: 404 Error
+description: Seite nicht gefunden
+robots: noindex, nofollow
+---
# 404 Error
-<!-- title: flatMark - Ein minimalistischer Website-Generator auf Markdown-Basis -->
-<!-- description: Keine Datenbank nötig, kein unnötiger Ballast – nur Markdown und eine Prise PHP. Ideal für kleine Websites, Portfolios oder Dokumentationen. Die Inhalte werden direkt aus dem Dateisystem geladen. Einfach Markdown-Dateien bearbeiten und loslegen. -->
-<!-- robots: index, follow -->
+---
+title: flatMark - Ein minimalistischer Website-Generator auf Markdown-Basis
+description: Keine Datenbank nötig, kein unnötiger Ballast – nur Markdown und eine Prise PHP. Ideal für kleine Websites, Portfolios oder Dokumentationen. Die Inhalte werden direkt aus dem Dateisystem geladen. Einfach Markdown-Dateien bearbeiten und loslegen.
+robots: index, follow
+---
{background color-02}{columns 33-66}
{img-rounded}
-<!-- title: 404 Not Found -->
-<!-- description: Page not found -->
-<!-- robots: noindex, nofollow -->
+---
+title: 404 Not Found
+description: Page not found
+robots: noindex, nofollow
+---
# 404 Not Found
-<!-- title: flatMark - lightweight, flat-file Markdown-based website generator -->
-<!-- description: No database required, no overhead in sight — just Markdown and a sprinkle of PHP. Ideal for small websites, portfolios, or documentation, it delivers content directly from the filesystem. Just edit your Markdown files and go. -->
-<!-- robots: index, follow -->
+---
+title: flatMark - lightweight, flat-file Markdown-based website generator
+description: No database required, no overhead in sight — just Markdown and a sprinkle of PHP. Ideal for small websites, portfolios, or documentation, it delivers content directly from the filesystem. Just edit your Markdown files and go.
+robots: index, follow
+---
{background color-02}{columns 33-66}
{img-rounded}