Pico CMS¶
Pico is a flat file CMS with a well thought through plugin system to extend its capabilities.
It's fast, it's light-weight and perfect for small websites.
- EOL, Compatibility, Updates
- Sessions und Twig
- Include Template Fragment in Page
- Render External Data from an API with Inline Twig Templates
- Table of Contents in Pages
EOL, Compatibility, Updates¶
As of 2026-05-14 (and earlier), Pico CMS is not developed further and issues arise mainly when bumping up the PHP version. There are several forks that address this. Generally, since Pico is so small, it should be easy to fix or to find a working fork.
https://github.com/picocms/Pico/issues/716#issuecomment-3684696214
Sessions und Twig¶
See session plugin and access via template vars: x
public function onPageRendering(Twig_Environment &$twig, array &$twigVariables, &$templateName)
{
$twig->addGlobal('session', $_SESSION);
//d($_SESSION,$twigVariables,$twig);
}
{ { session.username }}
Include Template Fragment in Page¶
Render twig template fragments in markdown page
# Wiki
This is my digital garden[^1]
{ % include 'wiki-posts.twig' %}
[^1]: <https://tomcritchlow.com/2019/02/17/building-digital-garden/>
<!-- wiki-posts.twig -->
<section id="blog-listing">
{ % for page in pages if not page.hidden %}
{#{ dump(page.meta) }#}
<article class="postx">
<header class="post-header">{ {page.Status}}
<h2 class="post-title">
<a href="{ { page.url }}" up-dash=".main" up-transition="cross-fade">{ { page.title }}</a> →
</h2>
</header>
</article>
{ % endfor %}
</section>
<?php
class TweakOutput extends AbstractPicoPlugin
{
const API_VERSION = 2;
protected $enabled = true;
public function onPageRendering(&$templateName, array &$twigVariables)
{
preg_match('/\<p>{ %\s+include\s+\'([a-z-]+\.twig)\'\s+%\}<\/p>/m', $twigVariables['content'], $matches);
if(!$matches) return;
$html = $this->getTwig()->render($matches[1], $twigVariables);
$twigVariables['content'] = str_replace($matches[0],$html, $twigVariables['content']);
}
}
Render External Data from an API with Inline Twig Templates¶
Table of Contents in Pages¶
https://github.com/caseyamcl/toc
# GIS, Geolocation
[TOC]
Links to location related stuff.
## Linklist
- bla
## More
<?php
class TweakOutput extends AbstractPicoPlugin
{
const API_VERSION = 2;
protected $enabled = true;
public function onContentParsed(&$content)
{
$markupFixer = new TOC\MarkupFixer();
$tocGenerator = new TOC\TocGenerator();
$content = $markupFixer->fix($content);
$toc = '<div class="toc">' . $tocGenerator->getHtmlMenu($content, 1,2) . '</div>';
if(strpos($content,'[TOC]') !== false)
{
$content = str_replace(['<p>[ TOC]</p>','[ TOC]'], $toc, $content);
}
}
}