Content:
- Manual to edit the OpenMRB website
Before working with Jekyll as a static website generator, we need to perform some installation steps. For Windows, follow this instruction video. If you are using Windows, consider downloading the Ubuntu app from the Windows Store (using the Linux Subsystem for Windows). We need to install:
- Ruby, a programming language that can run Jekyll
- Check your version:
ruby -v
(2.1 or higher needed) - Download for Windows (Mac already has it installed)
- RubyGems, a package manager for Ruby that can install, update and maintain Ruby programs. We later use it to install Jekyll
- Check your version:
gem -v
-
Install Jekyll using RubyGems:
-
gem install jekyll bundler
-
Check your version:
jekyll -v
-
This step assumes that you have git installed on your PC and already have a Github account.
-
Fork the OpenMRB website repository to your own account
-
Clone your forked repository to your Ubuntu/Linux environment (the environment that can run Jekyll). For example, make a directory “git” (
mkdir git
) to clone the current and future repositories in.-
cd git
-
git clone https://github.com/DorienHuijser/openmrbenelux.github.io.git
-
-
Go into your now created repository folder:
cd openmrbenelux.github.io
-
Set up the OpenMRB website repository as the upstream repository so you can push and pull to and from it directly:
- Check your remotes:
git remote -v
. There should already be anorigin
(i.e., the link from which you cloned). - Now also add the upstream repository:
git remote add upstream https://github.com/OpenMRBenelux/openmrbenelux.github.io.git
- If you check your remotes again with
git remote -v
, you will find both theorigin
and theupstream
repositories.
- Check your remotes:
-
Now you can update your own local copy of the repository with the changes made in the upstream (main) repository with
git pull upstream master
(when updating your master branch with the upstream master branch)- or:
git checkout [other branch]
followed bygit pull upstream [other branch]
(when updating another branch with the upstream's branch)
Watch this youtube playlist to learn more about the Jekyll static website generator.
- Move into the folder of the repository:
cd openmrbenelux.github.io
(or a longer path, e.g.,cd /mnt/c/Users/username/Documents/openmrbenelux.github.io
) - Make sure you are working on the correct branch:
git checkout [branchname]
- Edit the markdown (.md) files of the pages you want to edit. For example, use Atom or Typora or any other markdown editor [would recommend Typora because it also reads and allows editing html]. Save the changes.
- To see your changes locally, run
bundle exec jekyll serve
(see below) - If you are happy with your change, stage the change:
git add [filename]
orgit all -A .
(if you want to stage ALL changes made) - Commit your staged files:
git commit -m "Edit x"
- Push your changes to your fork (online copy):
git push origin [branch name]
- On Github, open a Pull Request to merge your changes with the openmrbenelux repository
There are currently 2 files with navigation menus which can be found in the
_data
folder of the repository:
navigation.yml
: This yml file (which can also be edited with a text editor) contains the menu as displayed at the top of the main page. It can unfortunately only contain 1 dropdown level!past-events.yml
is a menu that is only displayed on the pages of previous events via the front matter on those pages (menubar: past_events
).
If you want to move pages around:
- Edit the relevant .yml file. Make sure the file links to the correct markdown files (in the correct repository folder) and file is correctly formatted (.yml files are very sensitive to wrong tabs and dashes)
- Serve the website locally to make sure that your changes still result in a working website
- Save, stage and commit your changes
- Do a pull request
You can also create new menu bars in the same way as the existing ones: just
create a new .yml file and on the relevant pages, include
menubar: name_of_menufile.yml
in the frontmatter of the page.
Adding team members, advisors or speakers can be done by adding them to the
relevant .yml
files in the _data
folder. The page-team
and page-speakers
pages have been set up to read the content directly from there and generate the
HTML code automatically.
The CSS for those pages is being transferred or kept in the relevant files in
the _sass
folder.
The tables from the program are generated by _includes/program-table.html
.
This requires some input data to render the table.
Those data are in yml files in the _data
folder.
You can render a table inserting this in your markdown file:
{% include program-table.html program=site.data.program_2021 %}
To modify the layout of the table you can so so by modifying the file
_sass/_program.scss
.
-
Move into the correct folder:
cd openmrbenelux.github.io
-
Change to the correct branch:
git checkout [branchname]
-
Serve the website locally:
bundle exec jekyll serve
-
A text such as this will appear in your command window:
Auto-regeneration: enabled for '/home/dorienhuijser/git/openmrbenelux.github.io'
LiveReload address: http://127.0.0.1:35729
Server address: http://127.0.0.1:4000/
Server running... press ctrl-c to stop.
LiveReload: Browser connected
-
Copy the server address to your browser and check out the website locally in your browser!
-
If you want to stop serving (e.g., because you want to commit changes), press
CNTRL + C
...
Include info about formatting on the entire website vs. on separate pages
2019
,2020
and2021
folders contain the .md files which will be converted to html on the website_data
: contains menus (footer_menu, navigation and past_events) and information about the team and speakers which will be automatically rendered on the website_includes
: files that are referred to by_layouts
html files_layouts
: layouts, defined by the theme_products
: files with the content that are referred to in_layouts/content.html
. The content page itself just contains the text:layout: content
._sass
: layout specificationsassets
: mainly images (in ext_images folder)img
: some more imagesnode_modules
: stuff for the Bulma theme- Individual files:
- README.md: handy info about the Bulma theme
- _config.yml: see below
- index.md and other .md files: homepage and other pages that are not assigned to a specific year
-
_config.yml
: website settings. Allows defining default front matter:defaults:
-
scope:
path: ""
# which files to apply the formatting to, e.g., "projects" > only in projects folder
type: page
values:
layout: "page"
author: "authorname"
-
Gemfile
: stores all Ruby dependencies for the website (e.g. Jekyll, theme, plugins) -
index.md
: homepage, can be modified -
_layouts
folder: which layouts does the theme you are using have?layout: page
(front matter) refers topage.html
in this _layouts folder. You can also create a layout yourself (in html). This will override the layouts from the theme.{{ content }}
> placeholder variable that refers to all content created that uses that layout{{ layout.variablename }}
to access front matter variables in the layout{{ page.variablename }}
to access front matter variable from a page{{ site.variablename }}
to access site-level variables from the_config.yml
file- See all variables to refer to HERE
- Layouts can contain different layouts within them as well (defined as front
matter, e.g.,
layout: "wrapperlayout"
). This way you only need to define the "main" layout once.
-
_includes
: defines specific formatting pieces that you can refer to in_layouts
- e.g.
header.html
in_includes
folder:{% include header.html %}
in a layout - Include style information:
{% include header.html color="blue" %}
in a layout<h1 style="color: {{ include.color }}">{{ site.title }}</h1><hr><br>
inheader.html
- e.g.
-
_data
: yml, json or csv files. Can be accessed via a layout with{{ site.data.nameofdatafile }}
- or loop through the file:
{% for item in site.data.nameofdatafile %} #do something {% endfor %}
- or loop through the file:
Front matter
- Information about the pages (e.g., title, date, layout, author), written in either YML or JSON
- Custom front matter variables are also possible
- Affect the URL of the page. Use a permalink variable, so that the URL will not
break if the front matter changes
permalink: "/my-permanent-url/"
permalink: /:categories/:title
> takes the categories and title for the URL
Change the theme of the website:
- Go to rubygems.org and search for a new jekyll-theme that you like
- In the readme.md of the theme, there are usually instructions what to call the theme
- In the
Gemfile
: addgem "jekyll-new-theme-you-want-to-use"
- In the terminal: run
bundle install
to install all Gems in the Gemfile - In the
_config.yml
file, update thetheme
variable - Also check your pages/posts: do they use layouts that are included in the new
theme? (see
_layouts
folder)
Page names: hyphen (-) will become a space
Drafts: put in _drafts
folder, run jekyll serve --draft
to include in
website build
Looping through pages (for loops in layouts)
{% for page in site.pages %}
<li><a href="{{ page.url }}">{{page.title}}</a></li> # create a navigation list
{% endfor %}
Conditionals (if-else loops in layouts)
{% if page.title == "My First Post" and condition %} # and, or both possible
This is the first post
{% elsif page.title == "My Second Post"%}
This is the second post
{% else %}
This is another post
{% endif %}
Style navigation list
{% for page in site.pages %}
<li><a style="{% if page.url == page.url %}color:red{% endif %}" href="{{ page.url }}">{{page.title}}</a></li>
{% endfor%}
Static files
- Don't have front matter, e.g., jpeg, pdf, etc. files. Are automatically recognized by Jekyll, directory does not matter much. E.g., in a layout:
{% for file in site.static_files %}
{{ file.path }} {{ file.name }} <br>
{% endfor %}
-
Give them front matter: in
_config.yml
file:defaults:
- scope:
path: "assests/img"
values:
image: true
-
In layout, this front matter can now be accessed:
{% for file in site.static_files %}
{% if file.image %}
<img scr="{{file.path}}" alt="{file.name}"> # if the file is an img, show it
{% endif %}
{% endfor %}