Jekyll is a popular static site generator used by many developers and bloggers to create fast, secure, and customizable websites. One of its key features is the ability to customize permalinks, which are the URLs of your pages and posts. Properly configured permalinks can improve both SEO and user readability.

Why Customize Permalinks?

Default permalink structures in Jekyll often include unnecessary elements like dates or categories, which can make URLs long and less user-friendly. Custom permalinks allow you to create clean, descriptive URLs that are easier to read and remember. Additionally, well-structured URLs can enhance your site's SEO by including relevant keywords and avoiding duplicate content issues.

How to Customize Jekyll Permalinks

Jekyll enables permalink customization through the _config.yml file. You can set a global permalink structure or define specific patterns for individual posts or pages.

Setting a Global Permalink Structure

To set a default URL pattern for your entire site, add the permalink key to your _config.yml file:

Example:

permalink: /blog/:title/

This structure creates URLs like yourdomain.com/blog/my-article-title/.

Using Permalink Variables

Jekyll supports various variables to customize URL patterns:

  • :year – The publication year
  • :month – The publication month
  • :day – The publication day
  • :title – The post title
  • :categories – The post categories

For example, to include the date and title, you might use:

permalink: /:year/:month/:day/:title/

Best Practices for SEO and Readability

When customizing permalinks, keep these tips in mind:

  • Keep URLs concise: Avoid unnecessary words or parameters.
  • Include keywords: Use relevant keywords that reflect the content.
  • Use hyphens to separate words: Hyphens improve readability and SEO.
  • Avoid dates when unnecessary: Dates can become outdated and reduce content relevance.

By following these guidelines, you can create permalinks that are both user-friendly and optimized for search engines.

Conclusion

Customizing permalinks in Jekyll is a simple yet powerful way to improve your website's SEO and user experience. By carefully choosing URL structures that are clean, descriptive, and keyword-rich, you can make your content more accessible and attractive to both search engines and visitors.