The GBIF data blog is a markdown blog generated using hugo and currently hosted using Netlify. The blog uses a slightly modified theme called even.
- Write a post in markdown named
YYYY-MM-DD-your-post.md
- Save plots or images into folder named
./content/post/YYYY-MM-DD-your-post_files
# embed images with this template
![example](/post/YYYY-MM-DD-your-post_files/plot1.jpg)
- Copy/paste the header text into your
.md
file.
---
title: Your Title
author: Your Name
date: '2022-01-04'
slug: your-post
categories:
- GBIF
tags: []
lastmod: '2022-01-04T10:19:14+01:00'
draft: yes
keywords: []
description: ''
authors: ''
comment: no
toc: no
autoCollapseToc: no
postMetaInFooter: no
hiddenFromHomePage: no
contentCopyright: no
reward: no
mathjax: no
mathjaxEnableSingleDollar: no
mathjaxEnableAutoNumber: no
hideHeaderAndFooter: no
flowchartDiagrams:
enable: no
options: ''
sequenceDiagrams:
enable: no
options: ''
---
- Edit important fields in header text:
title: Your post
<- your titleauthors: Your Name
<- your author namedate: '2018-09-21'
<- the order the post will appear on blog. Does not necessarily have to be the same as the date inYYYY-MM-DD-your-post.md
.slug: your-post
<- name that will appear in the url https://data-blog.gbif.org/post/your-post/tags:
<- category tags for posthiddenFromHomePage: yes
<- keeps the post off of navigation as you work on it.draft: yes
<- keeps off the website as you work on it.
- Copy
YYYY-MM-DD-your-post.md
andYYYY-MM-DD-your-post_files
into./content/post/
.
├───content
├───post
├───YYYY-MM-DD-your-post.md
└───YYYY-MM-DD-your-post_files <- put images here
└───plot1.jpg
- Preview post using the preview site.
- Fix mistakes and push changes to gbif/data-blog until satisfied.
- Switch to
hiddenFromHomePage: no
anddraft: no
- Check your post at https://data-blog.gbif.org/post/your-post/ (Netlify will build your post automatically)
- Ask someone with admin access to https://discourse.gbif.org/ to turn on comments for you.
There is now a blog preview site.
This site will show all content on the blog and ignore draft: yes
. Note that if, however, hiddenFromHomePage: yes
, then your post still won't show up on the preview site homepage, but the page is still visible using the direct URL https://data-blog.gbif-uat.org/post/your-post-slug/.
The preview site is public, but not indexed by google.
Sometimes it's desirable to preview a post locally. If the site doesn't build on the preview site, then there may have been a build error. This can be de-bugged by building locally.
This is possible using hugo
. https://gohugo.io/installation/ (blog uses v0.91.2)
git clone https://github.com/gbif/data-blog # get the blog files
cd data-blog
hugo --buildDrafts # cmd to build site
hugo server # serve site locally
View the site at http://localhost:1313/. Note that the flag --buildDrafts
will build your post even if draft: yes
.
Posts should be written in markdown. If you are unfamiliar, you can use some of the links below.
Markdown files are just simple text files with an .md
extension.
A post can be done by simply copying an .md
into the gbif/data-blog ./content/post/
directory.
.
├───content
└───post <- put YYYY-MM-DD-your-post.md here
You can always link images from some online hosting service, but it is probably better to associate images directly with a blog post.
To host static content (images) associated with a particular blog post, you need to create a folder in the post directory. For YYYY-MM-DD-your-post.md
you can create a folder named ./content/post/YYYY-MM-DD-your-post_files/
.
.
├───content
├───post
├───YYYY-MM-DD-your-post.md
└───YYYY-MM-DD-your-post_files <- put images here
└───plot1.jpg
Then to link an image in markdown, use a path like this to the image.
![example](/post/YYYY-MM-DD-your-post_files/plot1.jpg)
Note the lack of /content/ in the path. This is because the image is being linked from the ./public/post/YYYY-MM-DD-your-post_files/
. The ./public/
folder becomes the .
root directory when the site is built by hugo.
Delete the .md
file from from 2 locations.
- Delete the
.md
file from./content/post/
.
.
├───content
└───post <- delete YYYY-MM-DD-your-post.md and image folder (if you added one)
- Delete the
.md
file from./public/post/
.
├───public
└───post <- delete YYYY-MM-DD-your-post.md and image folder (if you added one)
The build settings of the blog on netlify.
Repository: https://github.com/gbif/data-blog
Build command: hugo
Publish directory: public
Production branch: master
Branch deploys: Deploy only the production branch and its deploy previews
Public deploy logs: Logs are public
Build environment variables
HUGO_VERSION: 0.91.2
Build settings for the preview site.
Repository: https://github.com/gbif/data-blog
Build command: hugo --buildDrafts; echo -e "# robots.txt for data-blog.gbif-uat.org\n#\n\nUser-agent: *\nDisallow: /\n" > public/robots.txt
Publish directory: public
Production branch: master
Branch deploys: Deploy only the production branch and its deploy previews
Public deploy logs: Logs are public
Build environment variables
HUGO_VERSION: 0.91.2