Setting Up Jekyll on Windows
Although Jekyll is not officially supported on Windows, it still can be run. Here is how I set it up for this blog.
Start by uninstalling any old versions of Ruby that are installed, and install a recent stable version Eg. Ruby 2.7.5 with DevKit.
The RubyInstaller.org website lists Ruby version 3 for download, but pick Ruby 2.7 because it is more stable, having been tested by more users.
Ruby Version 2.7.1 with DevKit is the latest available within the 2.7.x version series at the time of this writing.
After downloading, execute the setup file.
After the installation, open a cmd.exe window and install the jekyll and bundler gems with “gem install package_name”. Then, create a subdirectory for the blog with “jekyll new directory_name”, enter the directory with “cd directory_name”, and install dependencies with “bundle install”.
If all goes well, there should not be any errors when installing the Jekyll gem.
On creating a new website project with the “jekyll new site_name” command, a new directory is created.
Open the folder with an editor of your choice (Eg. Visual Studio Code, Sublime Text, or Notepad++).
Edit the _config.yml file, start up the Jekyll server with “jekyll serve”, and open the site in a browser at http://localhost:4000 . When performing builds to deploy on a remote web server, build the HTML with “jekyll build” and upload the “_site” directory with an FTP client.
Upon making any changes to the posts or pages, the changes can be viewed by refreshing the browser window. Making changes to the config requires terminating and running again the “jekyll serve” command.
Set the “show_excerpts: true” setting within the Jekyll config file, and create a directory for static assets (Eg. images).
For pagination, Jekyll version 3 and higher require the gem “jekyll-paginate-v2”.
{% raw %}
gem install jekyll-paginate-v2
#Gemfile
gem "jekyll-paginate-v2"
#_config.yml
plugins:
- jekyll-feed
- jekyll-paginate-v2
#permalink: /:year/:month/
pagination:
enabled: true
per_page: 5
sort_reverse: true
sort_field: 'date'
title: ':title'
debug: true
trail:
before: 2
after: 2
#index.markdown
---
layout: home
pagination:
enabled: true
permalink: '/:num/'
---
#_layouts/home.html
{%- if paginator.posts.size > 0 -%}
<h2 class="post-list-heading">{{ page.list_title | default: "Posts" }}</h2>
<ul class="post-list">
{%- for post in paginator.posts -%}
<li>
{%- assign date_format = site.minima.date_format | default: "%b %-d, %Y" -%}
<span class="post-meta">{{ post.date | date: date_format }}</span>
<h3>
<a class="post-link" href="{{ post.url | relative_url }}">
{{ post.title | escape }}
</a>
</h3>
{%- if site.show_excerpts -%}
{{ post.excerpt }}
{%- endif -%}
</li>
{%- endfor -%}
</ul>
{% if paginator.total_pages > 1 %}
<ul class="pager">
{% if paginator.previous_page %}
<li class="previous">
<a href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}">← Newer Posts</a>
</li>
{% endif %}
{% if paginator.next_page %}
<li class="next">
<a href="{{ paginator.next_page_path | prepend: site.baseurl | replace: '//', '/' }}">Older Posts →</a>
</li>
{% endif %}
</ul>
{% endif %}
{% endraw %}