What are Markdown Blogging Alternatives

TYPO3, WordPress and Shopware are powerful tools for creating websites. What do they all have in common? They are based on PHP. Therefore, a PHP interpreter must be executed in addition to the web server when a site is called up. This reads the PHP code and executes it. This increases both latencies and the load on the server. In addition, updates that are not carried out regularly represent a considerable security risk. Therefore, today I would like to show you an alternative that works without PHP.
  1. Static Site Generators
  2. Hugo enters the ring
    1. Markdown language
    2. Metadata
    3. Manage Hugo website with Git
  3. The first Hugo website
  4. Conclusion

Static Site Generators (SSG), as their name describes, generate static websites. In the end, only HTML and CSS files are dropped, which can be delivered by the web server without the computationally intensive interpretation of PHP scripts. Thereby increase the speed and security of the website. Because apart from the web server in the form of Apache, nginx or similar, no other code is executed on the server that could possibly contain security gaps.

The disadvantage: reduced interactivity with the website. Javascript can still be integrated, but without code on the server side, the user input cannot simply be used. Yet SSG's tool set makes it easier to add new content, e.g. a blog article.

Hugo is an in Golang written SSG and had its first public release in 2013. The project describes itself as optimized for speed, simplicity and configurability and is designed for all types of websites. Most are supported common operating systems such as Windows, Linux and Mac - The generated HTML files can be delivered from any web server on any platform.

Markdown markdown language

The content for Hugo is written in the markdown language Markdown. This may sound complex at first, but it is very simple. That's how it's done:

---

title: "Blogging Without PHP"

date: 2020-09-15T11: 03: 25 + 02: 00

draft: true

---

 

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur rutrum odio a quam aliquet vehicula. In hac habitasse platea dictumst. Present iaculis erat ut justo eleifend egestas. Sed aliquam tristique mauris.

 

## Cras imperdiet arcu tincidunt ipsum tincidunt

 

Maecenas sollicitudin nibh nec orci rutrum, at sodales libero commodo. Morbi vel ultricies justo, eget varius lorem. Curabitur sagittis sit amet lacus sagittis ullamcorper. In eget facilis lectus. Fusce vitae diam varius, ultrices ligula sed, rhoncus felis.

In the beginning you have to have some Define metadata for Hugo: 'title' and 'date' are self-explanatory. The 'draft' metadata defines whether the article is only a draft and should therefore not be published when the website is created. If the article is finished, you set 'false' there. This is followed by the actual text. You mark subheadings with '##'. You can find more options for text formatting in the official Markdown specification.

Manage Hugo website with Git

The advantage of markup languages ‚Äč‚Äčlike Markdown is one simple versioning option, for example with the popular version management Git. Building on this, collaboration software such as Gitlab or Github can also be used to create the Cooperation with editors or simplify it for other authors. You can also have a continuous deployment process with any CI / CD tools create.

Hosting a website created by Hugo with Gitlab Pages could, for example, be implemented with the following gitlab-ci.yml.

image:

name: klakegg / hugo

entrypoint: [""]

 

variables:

GIT_SUBMODULE_STRATEGY: recursive

 

pages:

script:

- Hugo

artifacts:

paths:

- public

only:

- master

The 'public' folder contains the completed website after calling 'hugo'. Instead of leaving this folder to the Gitlab Pages, the Gitlab CI can also upload it to a web space via SSH or FTP. This will bring the site live as soon as changes land on the master branch of the Git repository.

The first Hugo website

So that you can start with Hugo, you have to Install the program on your own machine. How? This is described in the official Hugo installation instructions. You can create a new website as follows:

> hugo new site my blog

With this you create a new folder with the required structure.

> cd myblog / && ls

archetypes / config.toml content / data / layouts / static / themes /

In the file `config.toml` the` baseURL` is set to the domain under which the website should be accessible. You also have to set the `languageCode` to the code of the language you want to use. For German this is `de-de`. Then you should set the default language using the parameter `DefaultContentLanguage`. Only then will the standard texts from Hugo also be generated in German. Here `de` is enough for German. To define the theme to be used, add 'theme = ananke'.

The finished 'config.tom' looks like this:

baseURL = "http://example.org/" # replace with your own domain

languageCode = "de-de"

title = Replace "My New Hugo Site" # with your own title

theme = "thank you"

DefaultContentLanguage = "de"

The Ananke theme is not delivered together with Hugo. Therefore you have to install this extra:

> git init

> git submodule add https://github.com/budparr/gohugo-theme-ananke.git themes / ananke

Now you can add the first article with 'hugo new article / neue-artikel.md'. To see the result, Hugo brings a web server that you start with 'hugo server'. Do you want drafts to be displayed? Then add the following parameter: 'hugo server -D'.

Now start the server. The site can already be accessed via the URL http: // localhost: 1313 /.

Thanks to Hugo you can create simple, static websites easily and quicklywithout first having to familiarize yourself with the complexity of a CMS. There is also no need to configure a PHP interpreter or a database such as MySQL. The ability to manage your website in Git creates new ways of collaboration and automation. However, external services must be integrated for interactive elements such as a shopping cart.

Hopefully this article gave you a good first look into the world of static site generators. If you want to know more, you can find many more resources on website creation with Hugo in the official documentation. ;-) I wish you every success with the creation!

As a system developer at Mittwald, Fabian is responsible for the stability and further development of the server platform. In the blog he writes about interesting innovations and tools in the field of server administration, which enable the smooth operation of those at Mittwald.