Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jekyll without a theme

I'm trying to create a static website. I want to be able to do some simple preprocessing, such as including one page within another, without the use of PHP or JavaScript.

Jekyll seemed perfect for this, especially given its support on GitHub pages.

However, after trying a few themes and trying to tweak them into what I'd like, I found myself fighting the themes which made them more of a hindrance than helpful. As a result, I decided to try and work without them and just use Jekyll as a fancy preprocessor and plugin platform (for things such as jekyll-redirect-from).

Much to my surprise, I couldn't find any information on how to do this, on how and where to place what files to generate a useable site. It feels like this should be incredibly simple to do, but the only route I've found so far is to create my own theme. This seems like overkill to me.

TL;DR

How can I create a Jekyll site without using a theme? Where can I find information on what files I need, where, what needs to be in them and so on?

like image 599
OMGtechy Avatar asked Aug 08 '19 20:08

OMGtechy


People also ask

How do I override Jekyll theme?

However, you can override any of the theme defaults with your own site content. To replace layouts or includes in your theme, make a copy in your _layouts or _includes directory of the specific file you wish to modify, or create the file from scratch giving it the same name as the file you wish to override.

What is remote theme in Jekyll?

Remote themes are specified by the remote_theme key in the site's config. For public GitHub, remote themes must be in the form of OWNER/REPOSITORY , and must represent a public GitHub-hosted Jekyll theme. See the Jekyll documentation for more information on authoring a theme.

Is Hugo better than Jekyll?

For some sites with thousands of pages, Hugo is a must because of its build speed. For others, Jekyll can be a must because of a few plugins with specific functionalities not found in Hugo. But for the majority of us, it comes down to personal preference. So, you can't really go wrong with either Jekyll or Hugo.

Why Jekyll is a static website?

Jekyll is a static site generator. It takes text written in your favorite markup language and uses layouts to create a static website. You can tweak the site's look and feel, URLs, the data displayed on the page, and more.


1 Answers

You can invoke the jekyll new command with the --blank option as documented in the command line usage section of the docs.

That way Jekyll generates a basic project with empty folders and files.

Now start by creating your own layout in _layouts/my-fancy-layout.html:

<!DOCTYPE html>
<html>
  <head>
    <title>My Fancy Title</title>
  </head>
  <body>
    <p>Here comes my fancy content: </p>
    {{ content }}
  </body>
</html>

Next add some content to your index.html and tell it to use your layout:

---
layout: my-fancy-layout
---
<h1>Hello, World!</h1>

This is your basic Jekyll site with your custom layout :)

Further steps are:

  • reading about Jekylls directory structure to learn where each file goes
  • moving complex parts of your layout - like the head or a footer - in their own files in the _include directory and include them in all your layouts
  • taking a look a the variables section of the documentation and use page.name and page.title in your layout

By the way, I created my personal website that way and it works like a charm.

like image 61
kalehmann Avatar answered Nov 01 '22 09:11

kalehmann