Content & Templates
Installation
Herd
Vs Code
Plain Kit
https://herd.laravel.com/new/getkirby/plainkit
PHP
Crash course in PHP
Folder Structure
index.phpmain PHP filecontentsource of truth, data, or db for file based systemsiteplugins, blueprints, themesassetssupplementary files for sitekirbyCMS files. Update files here.mediaoptimized and managed by Kirby e.g. crop, optimize, etc.
Content Folder Structure
Why?
easy to create complex folder/file tree structures
folder content and structure should be able to exist and understand easily without the cms
Portable. Portable. Portability to take to ANY system. NO vendor lockin.
What?
contentfolder single source of truthdefault folders -
/content/error/error.txtdefault -/content/home/home.txtdefault -site.txtis the site objectEntry content is stored with the entry
Content Folders
Reference:
new custom content site path
/content/NameOfDirectorypicks up name of
NameOfDirectoryby default/content/NameOfDirectory/NameOfDirectory.txt
Sub Folders
`/content/NameOfDirectory/SubDirectoryp;-['/]
/content/NameOfDirectory/SubDirectory.txtEX:
create
/content/projectscreate
/content/projects.txtrepeat for
/content/teamand/conent/team.txt
EX:
manually sort content folders
prepend folder numbers
Front Matter Fields
Front Matter
fieldName:values----four dashes to separate fieldsfields are flexible and are not required
content can have no, all, any combo of fields
global content can also be stored in the root
content folderMetadata can be stored in same folder
FileName.ext.txtis associated with the file
Sorting
preprend numbers, labels, ids, etc. to folder names
Main Template
Why?
static templates that load content dynamically
D.R.Y. principles of programming
Easily change website look and feel without changing content
Main reason why CMSs exist
How?
/templates/defaults.php/templates/defaults.phpeverything is served from this default boilerplateresponsible for what gets sent to the browser
set HTML boilerplate here
EX:
output
$site->title
$pageobject most importantsee docs for this important object
$page->fieldName()outputs the field
$siteobject 2nd most importantsee docs for this important object
$site->url()$site->title()
css()loads CSS file via relative pathdynamically list navigation
default.phpgets HTML boilerplatePHP
foreach( $site->children() as $item)$item->url(),$item->title()$item->url(),$item->title()->listed()to get numbered directories
Sub Templates
Why?
Custom templates for each content types e.g. blog, portfolio, etc.
Extend the default template
How?
List content from folders
If
contentFolderNamematches thesite/templatesfile, it will load that file. E.g.content:
content/photos/photos.txttemplate:
site/templates/photos.phptemplates can be shared with other types of content
list children of directory with
$page->children()inforEach()loop
Entry Pages from Content
Why?
list sub content from within folders
How?
Snippets
Why?
D.R.Y. principles
How
create snippet in
snippets/snippetName.phptemplate files include by
snippet(snippetName)
Last updated
