web development  / 

A sample post with everything in it

Tons of layout and styling options — all set with plain-text Markdown and one image ‘shortcode’
This medium right image doesn’t dominate the page, and it can be viewed directly alongside related text

Starting off with the first image that appears alongside here at the top of this post. Demonstrating that this image doesn’t always have to be huge. In fact, any image in the post can be set to a small or a medium size, and aligned alongside any paragraph, if that’s more appropriate to the image quality, or the post’s content. There are lots more examples below.

If there is no image at the top, a nice ‘drop cap’ style is instead added automatically to the first letter of the first paragraph. I can’t show this here, but there are examples on many of my later posts.

In this demo post, intead of using ‘Lorem Ipsum’ dummy text, I’m going to try to describe the typography and layout from within the examples themselves. Like in this blockquote:

“With so many different elements crammed in together, this page will probably look a bit of a mess. But, I won’t properly find out how well these styles work, until I start using them for real posts.”
— Brian Liddell

I’ve used the (excellent) Tailwind CSS framework in all my templates. One of Tailwind’s key features is that it comes with no pre-set typography at all. So all the type styling has to be built up from a zero base, rather than hacking it down from the framework’s pre-set defaults.

I’ve started off with very basic typography, using only the Tailwind system default sans-serif and serif fonts — but mixing them up a bit, sometimes within the same sentence. For example, applying bold to these emboldened words changes their font family, as well as their font weight. Hopefully, this will add a bit of life to my minimalist design.

I want this to look like a personal website, rather than a corporate blog. That said, I’m looking forward to experimenting with more interesting typography and colours, sometime later on.

1  How the image layout options work

I’ve spent a crazy amount of time designing/evolving my website’s layout — aiming to create a varied and interesting gridat every breakpoint — and using the full screen width, not just the main text column.

I am a small left image

For example, the picture on the left remains aligned alongside this paragraph at all screen sizes, except for mobile screens, where it appears above.

This image’s file name, its size, its position, and its caption are all defined using a bracketed ‘shortcode’ called a KirbyTag, which is inserted inline with all the other text in Kirby’s Markdown editor. The KirbyTag for this particular image looks like this:

(img: geese.jpg class: small left caption: I am a **small left** image)

Because image KirbyTags are plain text, they can easily be moved, with a simple cut-and-paste, to appear alongside or above any other paragraph.

And also because they are just plain text — they are much less distracting than ‘Matrix’ or ‘Builder’ blocks when writing, or editing, the rest of the content.

I am a small right image

The class options for these image KirbyTags are really simple too:

  • Sizes are: tiny, mini, small, medium, large, or extra-large
  • Positions are: left, right, or center
  • and no-shadow or extra-shadow, to remove or increase their shadow outlines

This simple text-only markup means that both the image’s size and its position can be changed in an instant — a super-fast and powerful formatting tool, that I’ve used to create every post (and page) on this site.

2  More examples of image layout

As well as the right and left examples above, images can also be positioned in grid rows — set using class names, numbered one to five. No additional markup is needed, just a line of three spaced hyphens - - - to separate each row:

I am a class one image
I’m a two image
I’m a three image in a row

I am a four image
I am a five image

These - - - invisible separators split the ‘floated’ images above into horizontal rows. However, all the images below are sized and positioned to fill their rows, so they don’t need a separator between them:

I am a medium center image
(centered on the text column)
I’m a small center image
I’m a center image

I don’t expect to use these center images very often. I prefer images aligned at the left edge of the text column, with my favourite off-center class:

I’m a medium off-center image
I’m an off-center image

Images can be entered quickly, without specifying a class, and these default to fill the text-column width:

I’m a default image, and I don’t have a class!
I’m a large image
Extra-large is plenty big for my fuzzy photos
  • This wide range of options makes it easy to choose a display size that’s exactly right for the context and quality of each image.

  • Captions are aligned to stand out from the main text, yet they take up only the space they need.

  • I’m a huge fan of captions, and I use them wherever I can! But, I don’t like automated ‘gallery’ layouts, where images are butted up to each other, with no space for captions, and no regard for content or colour clashes.

  • I think my Markdown row layouts are a better alternative, offering lots more control, without losing the gallery aesthetic. There are several good examples in this cycle touring post.

Update, 7 June 2021: I’ve just added a Medium-style ‘zoom’ feature — so you can now click on (some) images on this page, and they’ll enlarge to fill the available space. This can be selectively applied to any image: by adding a zoom class to individual image KirbyTags, or (much quicker), by ticking a single checkbox in the control panel, to enable zooming for every image on the page.

3  Markdown text styles and spacing

The h1 heading above isn’t usually repeated in a blog post. However, h1 styles are needed for other non-blog pages, such as ‘home’ and ‘about’, and their use is permitted for major sections in longer blog posts like this.

Heading styles h1 to h4 are simple to set in Markdown, in lines beginning with to #### .

I am a medium right no-shadow image

This is an h2 heading

There is no bold in any heading style! Emboldened words in h1, h2, h3, and h4 headings are rendered in a red round-cornered box instead.

This is an h3 heading

Text below h1, h2, and h3 headings is spaced closely beneath them, like this.

This is an h4 heading

H4 headings are exactly the same as h3 headings, except the text above and below them is spaced tighter still.

I like to use longer h2 headings, sentence-case across multiple lines, to emphasise key points…

Space between successive headings is automatically set closer, like above this h3 heading

Below the next paragraph is a horizontal rule, entered in Markdown as a line of three hyphens ---.

These horizontal rules always clear the full page width — so if there is an image ‘floated’ to the right or left, the rule will go below it. Spacing for rules is always set automatically, depending on the content before and after:


This mini right image stays small, even on mobile

Headings are closely spaced below horizontal rules, contrasting with the extra space above them

This distinctive spacing is an effective way of structuring blocks of content, especially when aligned with an image alongside.



Sometimes it’s useful to add some extra space with a spacer. This is done by inserting another hidden separator — this time with a single line of three asterisks ***. And, if the following block is a text paragraph (like this one), this also automatically triggers a nice red drop-cap for the first letter.

All the main text and list typography is set (like this) to the same 18 px font size (16 px on mobile), and 1.5 line height, with a consistent spacing between every paragraph or list block.

Emphasised text looks like these emboldened words, or like these italicised words, and clickable KirbyTag links look like this: I am a link.


Highlighted, underlined, deleted, and Small Styles

Headings or text which are tagged <mark>like this</mark> are highlighted like this.

Underlined headings and text are marked up <u>like this</u> to look like this.

Deleted headings and text are marked up ~~like this~~ and look like this.

‘Small-cap’ headings and text are tagged <small>Like This</small> to make them look Like This.


Blockquotes, quote tags, and pull quotes

Blockquotes are marked-up with a simple > right-arrow-bracket before a block of text or a heading in Markdown. They’re a great way of highlighting key points, not just for quotations:

Blockquotes can contain h1, h2, h3, or h4 headings

— or default text like this, which can be emboldened or italicised or linked like this.

Quote tags are used <q>like this</q> to add, not only italic formatting, but also these funky red quotation marks: like this.

Pull quotes are created from quote tags — using the new ‘card’ layout styles I’ve added in an update at the end of this post.


Inline code and code blocks

Inline code is marked-up with back-ticks `like_this.php`, and will then be rendered like_this.php.

Code blocks are marked-up with a line of three back-ticks: ```, on the lines immediately before and after the enclosed code, and look like this:

<?php snippet('head') ?>
<?php snippet('header') ?>
<!-- longer lines of code will overflow, but can be horizontally scrolled like this -->

4  Markdown lists

Update, 20 November 2020: After several months of using Markdown in Kirby, I’ve only just discovered that there are two alternative list spacings available in its syntax:

If list items are separated by blank lines, Markdown will wrap the items in <p> tags in the HTML output
— John Gruber’s original docs

How could I fail to notice this terrific option, for so long?

This means I can abandon my previous hacky CSS to achieve different list spacings — and I’ve now re-coded all my Markdown lists with this much cleaner ‘blank-line’ mark-up…


An unordered list, with an h4 heading

  • Unordered list items are coded in Markdown - Like this
  • This standard unordered list is tight spaced, with the default sans-serif font
  • It’s useful for shorter lists of key points
  • It’s also handy for manually-entered ‘Notes’ after the last paragraph in a post

An ordered list, with an h4 heading

  1. Ordered list items are simple too: 1. Like this
  2. This is the same as the unordered list, but with nice (red) counters instead of bullets
  3. This is an ideal format for manually entered ‘Footnotes’ (until I get round to adding a Footnotes plugin)
  4. All the list items can be emboldened or italicised or linked exactly like before

A tiny right no-shadow image

An unordered list, with an h3 heading, and ‘blank-line’ spacing

  • This unordered list has the same spacing and serif font as the default paragraph text.

  • These wider spaced lists are ideal for longer sentences, or substantial paragraphs. Just as important, they’re a quick and easy way to add some structure to my writing!

  • The list items can be emboldened or italicised or linked exactly like before.


An ordered list with an h3 heading, and ‘blank-line’ spacing

  1. This is the same as the unordered list, but with bigger red counters.

  2. Again this wider spacing for lists is best suited to longer sentences, or substantial paragraphs. That’s why I’ve written this extra sentence to fill out this line.

  3. Lists look better with three items.


5  Final thoughts…

Designing these layouts at the same time as coding them has been a great way to learn and test my ideas, but incredibly inefficient and time consuming. If there is ever a next time, it would probably be much faster to learn Sketch or Figma first.

Using too many styles together (as on this example page) can look confusing and messy. So it’s important to use everything in moderation, and it will take time and practice to get this right.

Last but not least, here is a nice button, using simple <button></button> tags, to wrap the KirbyTag link:


Update, 25 January 2021: Card layouts

As well as the <button> and <mark> tags already sneaked into the Markdown above, I’ve now introduced one more HTML element to the mix.

By adding <aside> tags, and re-using existing image classes, I’ve created these new card layout styles:


Update, 9 March 2022: Horizontal cards layout

I’ve just added these ‘horizontal’ card layouts, with a smaller image always aligned to the right:

Cards are sized and positioned using existing image classes — but the size and position of their internal image is always automatic.

Pull quotes are created with quote tags inside cards, alongside or within the main text column.

Wrapping <cite></cite> tags around the text in a card adds italic styling and right alignment:

I’ve worked hard to simplify the markup for these cards, and to optimise their responsive behaviour. Hopefully I’ll write a more detailed example post, linked to here, when I’ve finished.

Update, 10 Apr 2022: Simplified syntax…

I’ve at last learned (just) enough Regex to use PHP’s preg_replace() function, and to make my tag syntax more consistent with Kirby’s shortcodes.

So, I can now (optionally) use <card class: large dark> instead of <aside class="large dark">. Yay!

Update, 13 May 2021: Markdown tables too!

Below are a few sample lines from a much larger table I’ve just compiled for this post — using the extended Markdown syntax for tables.

This table markup is wrapped in <aside class="table"></aside> tags. All its text styling is then automatic, and it can also be resized and positioned by adding any of the image classes described above.


Update, 30 June 2022: I’ve just learned how to create this simple dropdown, without using JavaScript!

How cool is that! The triangle and clickable heading are both styled automatically. No extra markup is needed, just these <details> and <summary> tags:

<details><summary>

### The dropdown heading goes here, with no extra markup…
</summary>

Dropdown content goes here, using existing Markdown styling…
</details>


Final update, 15 May 2021: I’m stopping now!

I realise that by adding these few HTML tags, I’ve broken my original claim in the headline of this post — that I’ve used just ‘one image shortcode’.

In my defence, these hacky departures from pure Markdown have enabled a surprising repertoire of layouts and fancy typography!

But, now I need to drag myself away from this obsessive tinkering, to write a few ‘real’ blog posts.

So, I’ll end here with an example of the little red star that’s added automatically to the final paragraph of every post.

Readers’ comments

  • Brian Liddell

    15 May 2021

    I’ve just updated my blog with a new comments plugin, so now you can let me know what you think in the panel below.

    Thanks!

  • Brian Liddell

    23 Oct 2021

    Cheat sheet for Markdown in comments:

    Italicised words are marked-up like this: *Italicised words*

    Emboldend words are marked-up like this: **Emboldend words**

    Blockquotes are marked-up like this: > Blockquotes…

    • Lists are marked-up like this: - Lists…
    1. Ordered lists are marked-up like this: 1. Ordered lists…

    Links are marked-up like this: [Links](https://example.com)

    Inline code is wrapped with single ` back-ticks

    Code blocks are wrapped with lines containing three back-ticks

    All other Markdown is ignored!

Add your comment…

Available formatting commands

Use Markdown commands or their HTML equivalents to add simple formatting to your comment:

Text markup
*italic*, **bold**, ~~strikethrough~~, `code` and <mark>marked text</mark>.
Lists
- Unordered item 1
- Unordered list item 2
1. Ordered list item 1
2. Ordered list item 2
Quotations
> Quoted text
Code blocks
```
// A simple code block
```
```php
// Some PHP code
phpinfo();
```
Links
[Link text](https://example.com)
Full URLs are automatically converted into links.