IT Notes

Yet another IT Blog

Introduction

Word of Warning: This Site is not about Grav. This is my blog and I will write up random articles about stuff I have been or am working on and might need to remember later. Not everything will be usefull for the random reader, since that is not my intention. But maybe you will find something usefull on this site and cheers to you.

I chose Grav by chance. I wanted an alternative to Wordpress, as I find it kind of unsexy and clonky. I thought of kirby but I didnt feel like paying the license fee. So I stumbled on Grav and instantly felt happy with it.

Here you will find some notes on installing and using Grav. As mentioned this is mostly a reminder for myself ;).

Grav is a so called flat file cms, which basically means it manages its content with files and not with a database. Its supposed to be slimm, performant and easy to use. Since its open source there is no fee and hopefully has good community support.

So lets and take Grav for a spin.

Installation

One can get Grav from its website getgrav.org. Click on Download and you'll find the first instructions. Lower down you can get to the proper documentation and find more installation instruction.

https://learn.getgrav.org/17/basics/installation

There are several ways to install Grav. Simply download the zip and unpack. But I chose to use composer to install it. I had to install composer, zip and git on my webhoster for composer to run through without complaints.

In my Webroot for the project I typed

composer create-project getgrav/grav .

And then opened my project domain in a browser to see the example page "Say Hello to Grav! ...". This page also offers first advice how to create a new page. The default template is nice and simple, with well formated text which is all I need for now.

Content creation

Pages

Create a page As this is a flat file cms you can edit pages directly on the filesystem. Pages can be found in the /user/pages folder. Creating a Folder like 03.mypage and adding a file named default.md creates a new page that will be added to the menu. In this file you can add content by using "Markdown format". You might have heard of it, but if your like me, you might have seen it in readme.md files and but have never really payed attention to it. This is cool because this gives me the opportunity to learn some more about Markdown format and my collegues might appriciate it if my readme files are prettier in future. Also there might be an opportunities to use a readme as a page or vice versa.

Following the documentation https://learn.getgrav.org/17/content/content-pages you get an overview of how content is structured and how to create it using Grav.

Here are some notes:

  • There are 3 types of Pages: Standard, Listing, Modular
  • All content pages are located in /user/pages and each pages should have its own folder
  • prefix 01. to the page folder lets you order the menu items
  • The sites entry point, ie home page can be set in the config file : system/config/system.yaml
  • Foldernames with a "_" (underscore) prefix mark Modules, these will only be shown on the page in which folder they are placed
  • Page slugs are the corresponding foldername without the prefix. 01.my-page would be /my-page
  • Pages without prefix are invisible and will not be shown in the menu. For example the error page.
  • There are several different setting for ordering Collections available.
  • Inside a Page folder the filename corresponds to the template name. Page files should end with .md to indicate they are Markdown-formatted files.
  • When making a blog you can use the manual summary separator "[blank line] === [blank line]" to manually set a summary, otherwise a automatic summary will be created from the first 300 (default value) lines.
  • tab ident creates a quote box usefull for code snipps
  • use a \ to escape markup like \*

Example Page:

---
title: Page Title
taxonomy:
    category: blog
---

# Page Title

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque porttitor eu
felis sed ornare. Sed a mauris venenatis, pulvinar velit vel, dictum enim. Phasellus
ac rutrum velit. **Nunc lorem** purus, hendrerit sit amet augue aliquet, iaculis
ultricies nisl. Suspendisse tincidunt euismod risus, _quis feugiat_ arcu tincidunt
eget. Nulla eros mi, commodo vel ipsum vel, aliquet congue odio. Class aptent taciti
sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Pellentesque
velit orci, laoreet at adipiscing eu, interdum quis nibh. Nunc a accumsan purus.

The section between the "---" is called YAML FrontMatter and allows settings to be made for the page. Below the content is added. Basic Formating options are:

  • # → Heading 1
  • ## → Heading 2, etc
  • * → Bold
  • _ → Italic

Todo:

  • Find out how to make a proper Blog with Grav CMS