Skip to content

Commit 4a5b1be

Browse files
committed
updated README with best practice jekyll notes for our site
1 parent 590a217 commit 4a5b1be

File tree

1 file changed

+57
-11
lines changed

1 file changed

+57
-11
lines changed

README.md

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,44 @@ For further notes see [Web development](#web-development) below.
2525
Check out the repository, edit the pages under `_posts`, and push
2626
commits. The published pages are on the *master* branch.
2727

28+
### File name
29+
2830
Blog posts should be placed under `_posts`. These should have names
2931
according to:
3032

3133
YEAR-MONTH-DAY-title.md
3234

3335
where `YEAR` is a four-digit number, and `MONTH` and `DAY` are both two-digit
34-
numbers. Each post should have a header with:
36+
numbers.
37+
38+
### Meta data header of markdown files
39+
40+
Each post should have a header with:
3541

3642
---
3743
layout: post
38-
title: The title of this post
44+
title: "The title of this post"
3945
---
4046

41-
in order for it to be picked up by the paginator. The `blog` directory should
42-
not be touched, as this is only here to set the paginator.
47+
in order for it to be picked up by the paginator. You *must* put the title in
48+
quotation marks if it contains special characters.
49+
50+
Other keys can be in the header (such as *date* (overrides file name date) or
51+
*order* (for [static pages](#static-pages))).
52+
53+
54+
### Section headers
55+
56+
* Do not put a title at the start of the post. The title from the metadata will
57+
create the level 1 header.
58+
* Do not use level 1 (`# ... #`) headers, level 1 is reserved for the overall
59+
title.
60+
* Use level 2 (`## ... ##`) or higher level headers.
61+
62+
63+
### Good to know
64+
65+
The `blog` directory should not be touched, as this is only here to set the paginator.
4366

4467
* The `_site` directory is generated by Jekyll on the GitHub server side and
4568
should not be included in commits.
@@ -100,34 +123,57 @@ including MathJax.
100123
Drop images into the `public/images` directory and include them like
101124

102125
```html
103-
<img src="{{site.images}}/imagename.png"
126+
<img src="{{ site.images }}/imagename.png"
104127
style="float: right" alt="alternative text" width="30%"/>
105128
```
106129

107130
or use Markdown
108131
```markdown
109-
![alternative text]({{site.images}}/imagename.png)
132+
![alternative text]({{ site.images }}/imagename.png)
110133
```
111134

112135

113136
### Notes on using Jekyll ###
114137

138+
#### Absolute site links
139+
115140
For links between pages to work, generate absolute links with `site.baseurl`
116141
liquid tag:
117142

118143
```
119-
[see citations]({{ site.baseurl }}/pages/citations
144+
[see citations]({{ site.baseurl }}/pages/citations)
120145
```
121146

122-
The example will link to the file `/pages/citations`. Also note that one does
123-
not need spaces between the configuration variable and the curly braces (i.e.
124-
`{{ site.baseurl }}/` as typical seen), so I avoid them to prevent the editor
125-
breaking the line inside the curly braces (which upsets Jekyll greatly).
147+
The example will link to the file `/pages/citations`.
148+
149+
**Note**: Always put a slash `/` *after* `{{ site.baseurl }}`.
126150

127151
We define additional variables in `_config.yml` and use them with liquid tags.
128152
In particular, the sidebar `_includes/sidebar.html` is configured with
129153
additional links that are all stored in the config file.
130154

155+
#### Links to blog posts
156+
Use the
157+
[post_url](https://jekyllrb.com/docs/liquid/tags/#linking-to-posts)
158+
liquid tag `{% post_url FILENAME_NO_SUFFIX %}`. *FILENAME_NO_SUFFIX*
159+
is something like "2025-02-11-GSOC2024-final-blog" to reference the
160+
file `_posts/2025-02-11-GSOC2024-final-blog.md`. Note that the `.md`
161+
suffix is *not* included.
162+
163+
Prefix with the baseurl so you use it something like
164+
```markdown
165+
See the [GSOC 2024 blog post]({{ site.baseurl }}/{% post_url 2025-02-11-GSOC2024-final-blog %})
166+
for more details.
167+
```
168+
169+
#### Liquid tags
170+
171+
One does not need spaces between the configuration variable and the
172+
curly braces (i.e. `{{ site.baseurl }}/` as typical seen). If you
173+
find that your editor breaks the line inside the curly braces
174+
(which upsets Jekyll greatly) then omit the space.
175+
176+
131177

132178
### Local testing ###
133179

0 commit comments

Comments
 (0)