Jekyll Tutorial: How to create an unidirectional site (r)

May 20, 2023

Send this to

Today, internet-based sites help to establish the online image, marketing your company as well as reaching prospective customers. The process of designing a website can be a daunting task.

In this article, we'll introduce you to one of the most well-known SSGs -Jekyll. We will discuss Jekyll Learn the fundamentals of the way it functions and then learn how to create static sites using it.

This is an live demonstration of the blog created by using Jekyll.

Blog website built with Jekyll
Blog site built using Jekyll

You can access it via the repository in this project's GitHub repository in case you'd like to look around.

What does it really mean to be Jekyll?

What do you think it is about Jekyll is that is what distinguishes Jekyll distinguish herself from the other SSGs:

  1. Rapid and secure Jekyll doesn't deal with server-side databases or scripting. It is less vulnerable to attack or security flaws. It creates static HTML documents. Your website will be rapid and safe.
  2. customizable: Jekyll is highly customizable, allowing you to make use of layouts and templates and also create plugins that can expand functionality.
  3. Simple to install: Jekyll generates static HTML files which are able to be uploaded onto hosting servers or websites without the requirement of an automated CMS.
  4. With a large community Jekyll has a large amount of developers as well as users. This means that plenty of help is on hand should you require assistance or would like to expand your website's capabilities.

How do I install Jekyll

It is essential to start the installation of Ruby on your computer prior to proceeding to installing Jekyll according to the Jekyll guideline.

How to Install Jekyll on macOS

As a default, Ruby arrives preinstalled in macOS It's however not recommended to utilize this version of Ruby to install Jekyll because of its age. In the case of Ventura which is Apple's most recent operating system, the version of Ruby used is 2.6.10 The most current version is 3.1.3 (as at the time this article is written).

In order to fix this for this issue it is necessary to install Ruby properly using a version control program such as Chruby. It is necessary for setting up the Homebrew program for your Mac first using the following command from the terminal.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

If the installation was successful, start and close Terminal After that, you can see if Homebrew is now ready via this command:

The Brew Doctor

If you notice " Your system is at the point of making", you can proceed to the installation of the chruby as well as ruby-install with the help of the commands in the following sequence:

Brew installs chruby and then install

It's now possible to get the most current version installed, 3.1.3 by using ruby-install. ruby-install software that you've installed recently:

ruby-install 3.1.3

The process should only take a few minutes. When it's completed, you'll able to configure your shell to run in a continuous fashion the chruby command by using this command.

echo "source $(brew --prefix)/opt/chruby/share/chruby/chruby.sh" >> ~/.zshrc echo "source $(brew --prefix)/opt/chruby/share/chruby/auto.sh" >> ~/.zshrc echo "chruby ruby-3.1.3" >> ~/.zshrc

You can now stop and relaunch the terminal. Make sure everything works using this command:

ruby V

It must declare that that it's 3.1.3.

Now you have Ruby's most current version installed on your personal computer. You are now ready to download the most current version of Jekyll as well as the bundler gem

gem install jekyll bundler

How to install Jekyll on Windows

For installing Ruby and Jekyll on a Windows system, you're advised to make use of RubyInstaller. RubyInstaller. It is done by downloading and installing the Ruby+Devkit version accessing this page RubyInstaller Downloads and selecting the standard alternatives for installing.

The final stage of the wizard installation procedure is the installing the ridk process. This lets you install gems. Read more via the RubyInstaller instruction manual.

Pick from the choices available MSYS2 or MINGW Development Toolchain. Open a new command prompt, then install Jekyll and Bundler with this command:

gem install jekyll bundler

What are you able to do to Make Sure Jekyll was properly installed

To confirm the accuracy of Jekyll is properly installed on your machine, you must open your terminal. Then use this command:

jekyll-v

If you are able to see version numbers, this indicates that Jekyll works correctly on your system. Now you're ready to start using Jekyll!

Jekyll Commands as well as Configuration

Before beginning to build and personalizing an unstructured website with Jekyll, it's important to know the various CLI commands and the settings of a configuration file.

Commands are available to Jekyll CLI

Here are some of the more well-known Jekyll Command Line commands. It is not necessary to remember the commands. You just need to know they exist You are welcome to go back to discover the actions each command performs when you see their usage further in this post.

  • jekyll built generates a static website page in the web site directory.
  • jekyll serve: Builds the site and starts a web server on your local machine, allowing you to preview the site in your browser at http://localhost:4000.
  • Jekyll New (site name Jekyll New (site name is a brand-new Jekyll website within a new directory. It is named after the of the site.
  • Jekyll Doctor: Offers advice on issues in configurations, dependencies or other components which could lead to problems.
  • Jekyll Clear Removes the site directory. It is the location where website documents are saved.
  • Jekyll Help offers documents to Jekyll.
  • Jekyll Service Draft Draft helps create and manage your Jekyll site, which also has content which belongs in Drafts Directory. draft directory.

It is also possible to make these commands more flexible by adding alternatives. Take a look at the complete list of Jekyll options and commands from Jekyll's document. Jekyll documentation.

Jekyll Configuration File

The Jekyll settings file is YAML file called _config.yml that contains options and settings for your Jekyll site. The file can be used to change various aspects of your site's appearance, like the title and description of your website, URL, as well as many other choices.

Below are a few of the most popular designs:

  • Title: Your title for your web page.
  • Description An introductory description of your site.
  • baseurl Your subdirectory for your site, if found in a subdirectory, the domain.
  • URL the URL format of your pages and posts.
  • includes: A list of directories and files that aren't included in the development of websites.
  • comprises: A list of directories or files that must be included when creating a web site.
  • paginate The amount of content to be shown per page, using pagination.
  • plugins: The following list contains Jekyll's HTML0-related plugins that are loaded.
  • themes In default it's set to minimum. The user can choose any other theme through setting the name for it as well as implementing other settings we will learn about further in this post.

In addition, you are able to create customized variables in the configuration file. These variables can be used to create template templates for the layouts of your website, and includes. It is possible to, for example make a variable named author_name and include it into your templates in the form of site.author_name and *|the character|""}.

To modify the configuration of your Jekyll settings file, you need to access it in your _config.yml file in the directory which is part of the Jekyll project directory. Use an editor for editing text, before making modifications.

NOTE: Any changes you modify the configuration file will take effect the next time that you build your site using Jekyll Build as well as jekyll service..

How do I best to build a Static Website using Jekyll?

If you're now running Jekyll in your system you are now able to create your own Jekyll static website in only a couple of minutes. Start your terminal, and follow this instruction:

The blog of Jekyll's new-joels

It is recommended to replace "joels-blog" by the most popular web site's title.

Create a Jekyll static website
Jekyll static website

Next, navigate into the folder for web. It will show an illustration of the Jekyll site structure that contains directories and files including:

+ _config.yml +-Posts +the Gemfile +--- Gemfile.lock +--- index.md plus the README.md

Let's look at what each directories and files are used for:

  • _config.yml: The Jekyll configuration file, which has the site's configuration and alternatives.
  • posts: A directory that contains your site's content (can include blog posts). These can be Markdown or HTML files with a specific file naming convention: YEAR-MONTH-DAY-title.MARKUP.
  • Gemfile and Gemfile.lock: Bundler uses these files for managing the Ruby gems on which your website is built.
  • index.md: The default homepage for your website is created through Markdown HTML as well as markdown documents.

There are a myriad of options for folders and files you can use to personalize your Jekyll website. They include:

  • is A directory that includes reuseable HTML fragments that are integrated into pages and designs. For example, navbars and footers e.t.c.
  • template: The index contains HTML layout templates, which define the structure and basic design of your websites.
  • assets This directory is comprised of all files used by your website like images or CSS files.
  • SASS: It contains Sass files that can be used to build CSS to your website.

The file structure can be a great starting point for your Jekyll project. It is however possible to modify it according to the needs of the project you are working on.

Quick Start Option: Use Our GitHub Template

If you prefer to start your own business using Jekyll CLI, you can start a Git repository with this "Hello World" Jekyll templateon GitHub. Choose this model and create an account for copying the starter code into an entirely new repository, of the confines of your GitHub account.

What can I do to preview a Jekyll website?

You now have an Jekyll website, but how are you going to do if would like to visit the website and see what it looks like prior to modifying it to satisfy the requirements of your customers? Launch your terminal and move into your project's directory after which you can follow the procedure in the following order:

Jekyll Service

The program will make an website folder, which contains the static files created through your web site project. It will also start the Jekyll server, and you can preview your site via http://localhost:4000.

When you access the URL from your web browser, you will see your Jekyll website with the minimal design.

Jekyll static site default appearance
Default appearance

How to Customize the appearance of a Jekyll Site

When you build a website by using Jekyll and make use of themes, it's possible to modify the website to meet your needs. Particularly, you may have to design new pages, alter the layout of a webpage and also alter the way objects look. This is all feasible using Jekyll.

How Front Matter Works in Jekyll

When you go through every blog or website within your folder for projects You'll notice an information block that is comprised of three circular circles (--) in the upper right on every page. It's called front issue.

It's a type of metadata employed in Jekyll for storing details on webpages or posts. The format is either YAML or JSON.

The code >--- descriptionreads "Welcome to Jekyll!" Description: "Introduction to what Jekyll is and how it works" Date: 023-03-07. 16:54:37 +0100. code> code>

The front matter contains a variety of different elements, such as the name for the post its description as well as dates. The elements can be utilized to alter the appearance of a layout for a website and also the blog post's text.

Jekyll analyses front matter information and utilizes it to generate the HTML that you would like to show on your site. Front matter is the way of defining several options like the layout, the permalink and the status of publication and much other.

What is the best way to configure Front Matter to be the default Front Matter

You may also configure your default front matter to make sure that there's no need to create the same front matter in different types of documents. For example, every blog post would have the author's name in the same format and the same layout. There is the option of defining a custom front matter in your _config.yml file to provide all blog posts.

The style of the file is somewhat complicated, however this is how it will appear when within. Copy the code below the first option within the _config.yml file:

defaults to scope:path "posts" The empty string is the same as all value in the file: layout: "post" author: "John Doe"

Once you've executed the jekyll procedure, you'll be aware that, even if you do not provide the design and name of every blog entry, you can access the blog entries in your file.

Notice: When you don't create a path for the files you haven't defined, your documents will be created based on the predefined front matter's values.

Pages are created within Jekyll

If you create a brand new file in the directories of the project's root, you are deemed to be a page. The name you assign to your file will be used in the URL. Therefore, it's important to give each page a an appealing name.

For example, if you want to create a page with the URL https://example.com/about, create a file named about.html or about.md. The extension determines the markup language is used for the text of the webpage (HTML and Markdown).

After you've completed documents Make sure you've included the proper the front matter as well as the content. Then save the document and update your Jekyll page using your browser. The refreshed page is accessible via the URL which is the same as the file's name.

A Jekyll page consisting of front matter and content
Front matter and Content

Designing Layouts Using Jekyll

Layouts are used to describe the layout and structure of your site's pages, as well as blog post. The majority of layouts are created using HTML code. It is possible to consider adding a footer, header or meta information within the meta data on your website.

Initial step is to create the layouts folder inside the directory containing directories of your project. Then, you should make a brand new file for every layout. It should be given the appropriate name that is appropriate for what the layout is intended to do. You could, for example, create a file called page.html to define the layouts that will be applied to every page on your website.

It is advised to determine the general structure of your layouts using HTML or some other markup language.

These placeholders may be utilized for any kind of dynamic data that is included within the layout like the page's title, the content and metadata. For instance, you could create a an elementary layout that includes the header as well as the footer, content and header areas like:

"DOCTYPE HTML" HTML1 page.title title of the pagetitle |||} page title page Title of the page

When it is built, Jekyll will replace the tag's content with the contents that are in navbar.html.

The includes directory can contain various types of files, such as HTML, Markdown, or Liquid files. You must ensure that your code doesn't get duplicated (Don't repeat it) so that it is possible to use your code again on different websites.

Looping through Posts within Jekyll

There is a possibility of creating your own blog website that will contain blog posts together. This means that you'll need to collect all the posts on your website and cycle through them. In Jekyll this is easy to do with the "% for % tag.

Each post published on a Jekyll website is saved within the site.posts variable. You can loop through posts with the post.title titlepost.title|title|post.title} Liquid variable to display the title of the post in this manner:

For the post to be posted on site.posts % post.title % the post.titlepost.title * Endfor* Endfor|}* Endfor

In addition, you may use Liquid variables to generate additional information on each blog post, like the post's date, author and even its name.

Posts in site.posts % post.title *| Post|Post|post} published at onpost.date "%B %-d " through post.author }|"%B %-d,  post.authorB %-d, "|"%} end of the year. %

In the example below you can see that you can see that the dates Liquid filter formats every post's date in an easy-to-read format that humans can understand.

Now you have an understanding of the fundamental design possibilities that you can use for the appearance of your Jekyll website. You don't have to utilize all features to create an initial Jekyll website completely from scratch, as you are able to search for themes that fit the specifications of your website and then add it to your Jekyll website.

How do I best to incorporate a theme into Jekyll Sites? Jekyll Website

There are many themes you could add and the best part is that for each one that you can find specific steps to installing them. You can find this information within the ReadMe document that is available on GitHub. You can duplicate the theme or if it is an existing gem-based, it is easier.

For this tutorial to read it, install a suitable blogging theme and modify it to have the appearance of your blog's site adapted. This is a Gen-based theme and you can access the the source codes along with instructions on GitHub.

To install a theme based on gemstones, you need to access your site's Gemfile and then add the gemstone that matches the theme you're looking to install. The theme we will use is the jekyll-theme-clean-blog. The theme that is default can be replaced by the minimal theme that is available from the Gemfile:

gem "jekyll-theme-clean-blog"

Make use of the bundle installation command within your website's directory in order to download the core of your theme, as well as its dependencies.

If your website's _config.yml file, you should add the following line to define the types of themes you'd like to use:

theme: jekyll-theme-clean-blog

The theme is now available for use.

It is recommended to remove any layouts in the directory layouts directory to avoid them overriding the design of your theme.

It is possible to find your layout's name file within the instruction manual for the theme you're using. For example, if you're using the jekyll-theme-clean-blog theme, the layout names for the index.html file is home, other pages is page, and all posts is post.

Last but not least, use the jekyll service to build and manage your new website. theme.

Jekyll blog static site
Jekyll blog can be described as a static website

That's it! It's done! Jekyll site should now be running the most current gem-based theme you've installed. You can modify the theme even more through changing the layout of your site's layouts directories.

Customize a Jekyll Theme

Once you've got the design and themes for your website, the next step will be to personalize your site according to your preferences and function as the intended manner. For example, images on pages or posts are not displayed rather they are displayed on a gray background.

It is possible to fix this problem by adding a front matter feature to each page and post by indicating where images are located that you wish to make use of. It is a fact that Jekyll assets, such as photos are saved in the assets folder. In this folder, users can create sub-folders in order for organizing your images.

Organizing image folder for Jekyll site
Image folder

Now you can incorporate your preferred background into the block that is in your front and include a hyperlink to the image. This is for example in your About page, this would be the block with the front matter.

Layout of the page: This is the code >--- page layout: The codes title of the page. The description of this page The page's title is. permalink: /about/ background: '/assets/images/about-page.jpeg' ---

Same applies to every page and post on your website will look similar to the following:

Background image is shown on the About page
Background images can be seen on the About page.

Another option to customize can be to change the navbar's options. In this case, for instance, you don't need an email sign-up form, and can remove the hyperlink in the menu bar's options. This can be done by looking over the code sources of the theme through the source code responsible for the navigation buttons, then copying the code precisely into the theme and eliminating any option that you do not require.

Links for navigation can be found within the directory'includes' navbar.html files. It's possible to make the file using the same code copied from your source code. It is then possible to remove the contact option or include any other option that you would like.

Customizing the navbar from the Jekyll theme
The navigation bar can be modified using the Jekyll theme

Once you have saved your project you'll see that the navigation options can be customized according to your preference:

Fully customized nav bar
Fully customized navigation bar

The final change is to make a blog page that will be a repository of all blog entries that is, you'll be able loop through the entire blog posts posted displayed on the page.

Create an post.html files posts.html and paste the following code into it:

The code >--- layout: Title of the page Description of our blog. Learn more about the blog, and stay up-to-date on exciting blog posts. background: '/assets/images/blog-page.jpeg' --- % for post in site.posts % post.title % if post.subtitle % post.subtitle % else % post.excerpt % endif % Posted by % if post.author % post.author % else % site.author % endif % on date: '%B %d, %Y' * % include read_time.html content=post.content % % endfor %

You can choose to alter the background to reflect your stored image. The code you have used above shows that you loop through the entire blog post to show all the articles within this post. The blog page will look when it is saved.

Adding a special posts page to display all posts
Posts page

What can I do to add Content to Jekyll's Website?

The time has come to create an Jekyll website, and then configure your website to meet the demands of. This is the last step of to add content or learn the ways content can be incorporated to the Jekyll site.

Every post is kept within the folder called post folder. Each post is stored in an identical format following the naming convention YYYY-MM-DD-title.md (or .html for HTML files). For example, if you want to create a post called "My First Post", create a 2023-03-08-my-first-post.md in the _posts directory.

For each post/content file, ensure that you provide the headline of the post on the top. The layout and the title together with the description, date and any other specifics.

Code >--- layout name of the blog post: "How to Read Books Tips and Strategies for Enhancing Learning" title: "Reading books is one of the most effective ways to absorb the most current knowledge, gain new perspectives, and widen the scope of your education." date: 2023-03-02 23:45:13 -0400 background: '/assets/images/blog/books.jpeg' ---

Then you can add your information beneath the block at the front of your webpage making use the HTML tag or Markdown syntax.

Adding new posts to the _posts folder
New content is posted in the folder _posts

Save the file, then Jekyll creates it and incorporate it on your site.

How Can You Install Your Jekyll Website

Prerequisites: Setting Up Your Jekyll Site

Review your Gemfile.lock file and ensure that it is on a platform that can be used on any device. If you want to check that every platform is correctly configured you can run this command:

bundle lock --add platform arm64-darwin-22 x64-mingw-ucrt-x86_64-linux

Once you've done that then you'll be able to complete the creation of a Procfile -- this document defines the commands that will run each time the website is opened. This file is automatically updated with the commands that will be executed on the Process tab within My. This is the command that you wish to include in the Procfile.

internet: package exec jekyll build and ruby run -e httpd website

Create your Jekyll website available to GitHub

This article will take advantage of Git commands to publish our code to the GitHub. First, sign up for an account with GitHub before granting an access right to the address of the repository.

You can now create a local Git repository by using the terminal. Begin by choosing the directory that is the location of your project then using the following command:

the git process

Then, add the code into the local Git repository by using the following command:

Incorporate into Git

Now you can make changes to the settings you've created using this command

commit to Git with"-m "my my first commit"

Note: You can replace "my first commit" by a short note that explains your changes.

Then, you can post your code on GitHub by following the steps:

Gi remote Add the URL of origin and repository URL. Gi push -u master of source

NOTE: Ensure you replace "[repository URL"[repository URL[repository URL"[repository URL][repository URL]" by your individual GitHub URL for your repository.

After you've finished all these steps, your code will upload to GitHub. Your code will be made available via the URL of the repository you have created. You can now deploy it to !

Implementing Your Jekyll Site

These steps will help you deploy your Jekyll website:

  1. Simply click Applications to the left of the sidebar
  2. Click "Add the service"
  3. Simply click the app in the drop-down menu.
Deploying to ’s application hosting
The process for deployment takes place by hosting the application.

The window that opens will appear in which you have the option of selecting the repository you want to make available. Select the branch you'd like to set on the shelf if there are many branches within the repository.

Successful deployment of Jekyll static site
The deployment went well for Jekyll static sites

Your app will be deploying. Within hours, a link will be sent out to enable users to access the version that was deployed on your website. In this case, it is: https://myblog-84b54..app/

Summary

At this point, you've discovered how Jekyll operates and also possibilities for customizing which you are able to create using Jekyll. We can now declare that Jekyll is an excellent device for static sites because of its simple design, versatility and strong attributes.

Jekyll's intuitive templating system using liquid templates, along with built-in support for markdown, as well as other markup languages makes it simple to create and maintain websites with lots of content quickly.

What do you think about Jekyll? Do you have experience using Jekyll to create any kind of website? We invite you to share your experiences and work with us through comments in the section of comments below.

  • Simple management and setup on My dashboard My dashboard
  • Support is available 24/7.
  • The top Google Cloud Platform hardware and network powered by Kubernetes to ensure the most scalable capacity
  • Enterprise-grade Cloudflare integration, which increases the speed and security
  • The reach of the global viewers is further enhanced due to the possibility of 35 data centers in addition to more than 275 pop-ups over the world

The article was first reported here. here

Article was posted on here