als antwoord op forum.getkirby.com

I just wanted to add my 2 cents to this :)

I run my personal blog on Kirby, but since I've gone Indieweb, I've imported all Twitter and Instagram posts I ever posted. Recently I started to use Foursquare/Swarm, so I'm adding about 6 posts a day. At the moment of writing I have 8884 posts, in a folder structure with one folder per year, with folders per day of the year, with folders for every post (YYYY/DDD/N, I'm rewriting URLs to get /YYYY/MM/DD/N/optional-slug). On top of that I have views for only blogposts, photo's, checkins, and every category/hashtag is searchable.

I have to admit that I got rid of the panel, but that is because I don't like that it leaves empty fields written out in my content files. (I have a lot of optional fields.) But I do think my site could run with the panel. It might need one panel.page.create hook, but that's all.

I use Kirby's standard folder structure, but index it with a database. The database is just an index, so I can get rid of it at any time I feel like and regenerate it. The main content is stored in the .txt-file and if you visit a post-permalink, I don't access the database at all. The database is only used for the feeds and the category/tag-searches.

Because of all my optional fields, I have quite a lot of template-logic, so I cache the HTML-files of the 'entry' snippet. (one permalink version and one feed version) The rest of the page is still rendered without cache, it's just the entry part (the white block in my current design), and it's still fast enough to do the caching on the first load after update. I use this caching moment to update the database/index.

So I do the following on page-load:

  • if there is a .html version, and the f::modified() of the .txt version is older, and the snippet is also not modified
    • return the cached html (stop here)
  • if the is no .html version or the .txt was modified
    • update the index/db
  • generate a new .html version from the snippet and return that.

This way I can update via Micropub, via the Panel, via $page->update() or even via FTP, and the db will be updated on next visit of that page.

The only caveat is that the post will not show up in the stream if no-one has visited it yet, so I have added an indexer::add($page) to my Micropub endpoint, and would have to add one on the panel.page.create (and why not also update) hooks. When updating via FTP I have to make sure to visit the page.

All in all, now my site is fast, and still has the benefits of Kirby's very readable file system.

Please shoot criticism my way now ;)