WoJ
WoJ

Reputation: 29967

Why pages are not generated for a site created with --blank?

Note: I may have hit an edge case for Jekyll running in a Linux for Windows 10 environment. The same data used on pure Windows or in pure Linux work as expected (after the modifications following @marcanuy's answer). I will be back after more testing.

I created a new site via

jekyll new myblog --blank

This created the expected structure in myblog. I added a template _layouts/docs.html

<h1>hello world</h1>

{{ content }}

I then created a _posts/hello.md file:

---
title = the hello world page
layout = docs
---

# this is a hello world page

Hello world everyone

After running

# jekyll build
Configuration file: none
            Source: /root/myblog
       Destination: /root/myblog/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
                    done in 0.03 seconds.
 Auto-regeneration: disabled. Use --watch to enable.

my _site folder is empty, except for an index.html file copied from the root of my blog (copied verbatim - this is the content I put in index.html in the root)

Why isn't hello.html generated? I expected it to contain

<h1>hello world</h1>

<h1>this is a hello world page</h1>

Hello world everyone

Upvotes: 0

Views: 360

Answers (1)

marcanuy
marcanuy

Reputation: 23942

There are two problems that makes jekyll not build the "hello" page:

filename

  • if you put hello.md inside the _posts folder, then the correct filename should contain post's date like: 2017-05-21-hello.md

Then it will be available:

.
├── _drafts
├── index.html
├── _layouts
│   └── docs.html
├── _posts
│   └── 2017-05-21-hello.md
└── _site
    ├── hello.html
    └── index.html

Another approach is to publish it as a page:

  • in /hello.md, i.e.: at root level (not inside /_posts)

    .
    ├── _drafts
    ├── hello.md
    ├── index.html
    ├── _layouts
    │   └── docs.html
    ├── _posts
    └── _site
    ├── hello.html
    └── index.html
    

frontmatter

The other problem is the syntax of the front matter of hello.md, each attribute should be defined with : instead of =:

---
title: the hello world page
layout: docs
---

# this is a hello world page

Hello world everyone

Upvotes: 1

Related Questions