简体   繁体   中英

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?

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM