Support Online
Skip to main content

URL and Link Management in Jekyll (Ultimate Guide)

💡 What You Will Learn in This Guide

Jekyll creates fast and secure static sites without a database. In this guide, you'll learn how to edit your site's URL structure, create unbreakable internal links, and test them in a staging environment. You will also increase SEO compatibility by optimizing permalink patterns with the _config.yml file.


🧠 Technical Summary

In this guide:

  1. You will learn how Jekyll's default file structure is reflected in URLs.
  2. With the _config.yml file you will change the URL pattern throughout the site.
  3. You will create dynamic links using the post_url tag with the Liquid template system.
  4. You will test connections in the staging environment using Nginx.

⚙️ 1. Understanding the Default URL Structure

Jekyll mirrors the directory structure in the _site folder directly into the URL. That is, the file path is exactly the same as your site's URL.

Example:

/posts/2025/11/04/ilk-yazi.html

This URL represents a dated file in the _posts folder.

If the pages (e.g. contact.md) are in the root directory, it will be /contact.html. Understanding this structure is the first step in permalink editing.


To change the URL pattern for the entire site, add the following line to _config.yml:

permalink: /:categories/:title/

This setting removes date information and creates plain URLs with category and title.

Restart the server to apply the changes:

CTRL+C
jekyll serve --host=192.168.1.100

Jekyll only applies changes on restart.


Hardcoded links break when you change the URL structure. Instead, use the tag post_url using Jekyll's Liquid template system.

Create a new post:

nano ~/www/_posts/2025-11-04-link-testi.md

Write the content as follows:

---
layout: post
date: 2025-11-04 10:00
title: Link Testi
---

Bağlantı testleri:

* [Mutlak Link](http://192.168.1.100:4000/hakkinda/)
* [Kök-Bağıl Link](/jekyll/update/hos-geldiniz/)
* [Jekyll post_url Linki]({% post_url 2025-11-04-link-testi %})

The post_url tag automatically finds the path to the post and creates an unbreakable link.


🧪 4. Testing on Staging

Test the site on Nginx before going live.

Install Nginx:

sudo apt update
sudo apt install nginx

Turn on HTTP traffic:

sudo ufw allow http

Copy the static site files to the Nginx root directory:

sudo rsync -av ~/www/_site/ /var/www/html/

This command moves the contents of _site to the directory served by Nginx.

Go to http://192.168.1.100 from the browser and test the connections.

  • Absolute link: If there is a port difference, it will be broken.
  • Root-relative link: It may break if the URL structure changes.
  • post_url link: Works in every environment.

Post-test cleaning:

sudo systemctl stop nginx
sudo ufw delete allow http

Maintain security by closing unnecessary open ports.


❓ Frequently Asked Questions (FAQ)

1. What is a permalink and why is it important?

Permalink is the permanent URL of a page. Stable and readable URLs are important for SEO.

2. Does the post_url tag work on pages?

Currently it only works on posts. You can use root-relative links for pages.

3. What happens to old links when the URL changes in Jekyll?

Hardlinks are broken, but those created with the tag post_url continue to work.

4. How to do automatic link checking?

You can automatically test all the links on your site with the html-proofer tool.

5. Why should I restart Jekyll serve after making changes?

Because Jekyll only loads the _config.yml changes on reboot.


🎯 Result

You now have full control of URL structures and link management on your Jekyll site. You can increase your SEO performance with permalink patterns and create unbreakable links with post_url. 💡 You can publish your static sites safely, quickly and uninterruptedly by hosting them on GenixNode.