Jekyll Tips
I am planning to update this post if I see some good tips for Jekyll. If you have also some suggestions, please feel free to get in touch.
Which sites you are using as a reference?
- Jekyll Official Documentation
- Jekyll Official Tutorials
- DEVHINTS.IO Jekyll Cheat-sheet
- Liquid Documentation
- Emojipedia ☺
- Markdown Guide
How to create an internal link?
Most of the time you need to create an internal link in one post to another. In this case, you can use the following syntax. I would like to give an example from my page.
[Blogging Manifesto]({% post_url 2019-10-05-blogging-manifesto %})
Reference: Linking to posts
How to organize files except for markdown files?
Especially the images in the post can be a problem. You should place the files assets directory. For more information please check here.
I create a separate directory for each post has the same base file name. For example, if the Markdown file name is 2019-10-05-blogging-manifesto.md, I create a directory in the assets directory with 2019-10-05-blogging-manifesto name. In that way, every file stays in the repository in a structured way. But here comes another problem, should I write all the time the path in the markdown? Assume that I have created an image file like /assets/2019-10-11-how-to-create-a-blog/01-new-repository.png, how should I reference that file? Check the following markdown:
![New Repository](/assets/2019-10-11-how-to-create-a-blog/01-new-repository.png)
Wow, how dirty it is. Another problem comes if I rename the post. My solution to that problem is creating a variable at the top of the file like:
{% assign post_assets = page.path | split: "/" | last | split: "." | first | prepend: "/assets/" %}
And the link becomes:
![New Repository]({{ post_assets }}/01-new-repository.png)
There are also some drawbacks. It does not support markdown files in the directories right now. If you have another solution to that problem something a more suitable variable in Jekyll, I would be very glad, my Jekyll knowledge currently is limited.