How To Get Jekyll To Use Css In Assets

Getting Jekyll to use CSS in assets is an essential part of customizing your Jekyll website. As a developer who enjoys creating visually appealing websites, I understand the importance of implementing CSS effectively. In this article, I will guide you through the process of setting up and using CSS in the assets folder of a Jekyll project.

Understanding the Assets Folder

The assets folder in a Jekyll project is where you can store your static files such as CSS, JavaScript, images, and more. This folder is a great place to organize all your site’s assets, making it easier to manage and maintain your project.

Adding CSS to the Assets Folder

First, navigate to the root directory of your Jekyll project. Inside the assets folder, create a new directory named css. This directory will house all your CSS files. You can also create subdirectories within the css folder to further organize your stylesheets.

Linking CSS to your Jekyll Layout

Now that you have your CSS file(s) in the assets folder, it’s time to link them to your Jekyll layout. Open your layout file (usually named default.html or something similar) and add the following line within the <head> tags:

<link rel="stylesheet" href="{{ '/assets/css/mystyle.css' | relative_url }}">

Personal Commentary

Implementing CSS in the assets folder is a game-changer for me. It allows me to keep my project organized and easily maintainable. I particularly enjoy structuring my CSS files within the assets directory, knowing that I can effortlessly link them to my layouts.

Conclusion

By leveraging the assets folder in Jekyll, you can effectively manage and use CSS in your project. This approach not only promotes organization but also simplifies the process of linking stylesheets to your Jekyll layout files. Give it a try and experience the benefits firsthand.