diff --git a/.editorconfig b/.editorconfig index 2a79307f..cccdb61c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -17,7 +17,7 @@ indent_style = space indent_size = 4 [*.md] -max_line_length = 80 +max_line_length = 120 trim_trailing_whitespace = false [*.js] diff --git a/README.md b/README.md index fe3ae6c3..06e7ed0e 100644 --- a/README.md +++ b/README.md @@ -70,5 +70,6 @@ Stenope is not a ready-to-use bloging system: but you could quickly _write your -- [Data manipulation: writing a custom Processor](doc/processors.md) +- [Data manipulation: writing a custom Processor](doc/cookbooks/processors.md) +- [Exposing a not found page](doc/cookbooks/not-found-page.md) diff --git a/doc/app/src/Controller/DocController.php b/doc/app/src/Controller/DocController.php index 57b06987..b9808241 100644 --- a/doc/app/src/Controller/DocController.php +++ b/doc/app/src/Controller/DocController.php @@ -25,7 +25,7 @@ public function index() return $this->render('doc/index.html.twig', ['page' => $page]); } - #[Route('/{page}', name: 'page')] + #[Route('/{page<.+>}', name: 'page')] public function page(Page $page) { return $this->render('doc/page.html.twig', ['page' => $page]); diff --git a/doc/cookbooks/not-found-page.md b/doc/cookbooks/not-found-page.md new file mode 100644 index 00000000..5ce31d57 --- /dev/null +++ b/doc/cookbooks/not-found-page.md @@ -0,0 +1,57 @@ +# Exposing a not found page + +Since Stenope is a static site generator, it does not handle 404 errors for missing pages. +Instead, your web server should handle them. + +However, you can let Stenope generate a 404.html page for you, and let your web server serve it. + +For instance, add in your `config/routes.yaml`: + +```yaml +errors_404: + path: 404.html + controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController + defaults: + template: errors/404.html.twig + options: + stenope: + sitemap: false +``` + +and create the `templates/errors/404.html.twig` template: + +```twig +{% extends 'base.html.twig' %} + +{% block title %}Page not found{% endblock %} + +{% block content %} +

404 Not Found

+ +

The page you are looking for does not exist.

+{% endblock %} +``` + +Then, configure your web server to serve this page when a 404 error occurs. + +Nginx: + +```nginx +server { + # […] + + location / { + try_files $uri $uri/index.html =404; + } + location ~ \.html { + internal; + } + + error_page 404 /404.html; +``` + +Apache: + +```apacheconf +ErrorDocument 404 /404.html +``` diff --git a/doc/processors.md b/doc/cookbooks/processors.md similarity index 100% rename from doc/processors.md rename to doc/cookbooks/processors.md