Jekyll, a popular static site generator, offers a straightforward way to build and manage your blog or website. Sometimes, you might find yourself needing to hide or disable a post. This could be because you’re working on a draft that’s not ready for the public eye, or perhaps you wish to deactivate an existing post without completely deleting it. Whatever the reason, Jekyll provides simple methods to achieve this, ensuring your site only displays content that’s ready and relevant.

Why Hide a Post?

Working on a Draft

Drafting is an essential part of content creation. Not every piece of writing is ready for immediate publication. You might want to preview your draft in the actual environment of your site, test different layouts, or share it with a select few for feedback. By hiding your draft post, you can work on it directly in the Jekyll environment without exposing it to all your site’s visitors.

Deactivating an Existing Post

There are occasions when you might need to temporarily or permanently remove a post from your site’s public view. This could be due to outdated content, a change in your site’s focus, or the need to revise a post extensively. Instead of deleting the post, which would remove it entirely from your project, hiding it allows you to keep the post for future reference or reactivation.

How to Hide or Disable a Post in Jekyll?

Hiding a Draft Post

  1. Use the Drafts Folder: Jekyll considers any file in the _drafts folder as a draft. Simply place your post in the _drafts directory of your Jekyll project. These posts won’t be published or included in your site’s content until you move them to the _posts folder.

  2. Set the published Variable: In the front matter of your post, you can control whether it gets published by setting the published variable. To hide a post, set this variable to false.

---
title: "My Draft Post"
date: 2024-02-04
published: false
---

Deactivating an Existing Post

To deactivate an existing post, you can either move it to the _drafts folder or use the published: false method mentioned above. This ensures the post is not visible to your audience but remains in your project files for future use.

Conclusion

Hiding or disabling posts in Jekyll is a handy feature for content management. Whether you’re refining drafts or managing your site’s published content, these methods provide flexibility and control over what your audience sees. Remember, a well-maintained site keeps content relevant and engaging for its visitors. Use these tips to effectively manage your drafts and posts, ensuring your Jekyll site remains organized and up-to-date.