This is meant as an example post for group members to use as a reference when writing their own blog posts.

You can inspect the source code inside _posts/2021-02-12-example.md to see how to create posts like this. Note that the first paragraph is displayed in the ‘preview’ on the front page; you can use that to your advantage to provide a short ‘blurb’ about your post.

In Markdown, single line breaks don’t create a new paragraph, so I recommend using one line per sentence to keep lines short. To make a new paragraph you need two line breaks.

Code blocks

Note that the syntax highlighting is a Liquid feature, not a Markdown feature. Liquid is kind of a HTML templating “language” and is recognisable by the {% ... %} directives in the source code.

Here’s an example of Python syntax highlighting. If you type the following code in your Markdown file:

{% highlight python %}
def fib(n):
    # this is mildly inefficient because if you call fib(1000)
    # followed by fib(1001) it has to calculate the first 1000
    # elements twice.
    fibs = [0, 1]
    if n > 1:
        for i in range(2, n + 1):
            fibs.append(fibs[i - 1] + fibs[i - 2])
    return fibs[n]
{% endhighlight %}

It will be rendered in the final webpage as:

def fib(n):
    # this is mildly inefficient because if you call fib(1000)
    # followed by fib(1001) it has to calculate the first 1000
    # elements twice.
    fibs = [0, 1]
    if n > 1:
        for i in range(2, n + 1):
            fibs.append(fibs[i - 1] + fibs[i - 2])
    return fibs[n]

You can do other languages as well, here Haskell (simply swap highlight python for highlight haskell):

fibs :: [Int]
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
-- actually this is more like a Python generator than a list
-- because of lazy evaluation. It also doesn't suffer from the
-- Python problem: once the first 1000 elements are calculated
-- they're there forever

fib :: Int -> Int
fib n = fibs !! n   -- !! is the indexing operator

Math can be rendered with MathJax

(which is mostly like LaTeX, except that you cannot load arbitrary packages)

If you type:

$$\mathrm{i}\hbar \frac{\partial}{\partial t} |\Psi\rangle = \hat{H}|\Psi\rangle$$

you can get:

\[\mathrm{i}\hbar \frac{\partial}{\partial t} |\Psi\rangle = \hat{H}|\Psi\rangle\]

The mhchem package works but unlike in LaTeX you need to use math mode (otherwise it won’t be parsed by MathJax):

$$\ce{H2O <=> H+ + OH-}$$

\[\ce{H2O <=> H+ + OH-}\]