6
votes

I created blog on github for a project using automatic generator and now I want to add new post. I added _posts folder and put file named 2015-04-05-post-name.md. Then I pushed all changes to repo on github. New page became available however it is not styled as index.html.

What do I do wrong? What I'm trying to achive is to be able to add new posts written in markdown but without installing jekyll on my pc. All new posts should look according to the overall style of blog.

Content of file looks like:

---
layout: post
title: Test Title
---

# First Post Header

Some text goes here.
4
"What do I do wrong?" It's pretty hard to answer that without seeing the code... Perhaps you forgot the YAML Front Matter? Or part of it, like the layout? Please add at least a partial example to your question.Chris
@Chris I added an example to the questionako
That post content looks reasonable. How is it rendering, and how do you expect it to render? Can you link directly to the site?Chris

4 Answers

3
votes

Automatic generator is not for Jekyll, its for normal standalone html pages. You should start from here: barryclark/jekyll-now [github]

If you want a tool to make it easier to post to your Jekyll blog/website then there is Prose.io. According to their website:

It's a web-based interface for managing content on GitHub. Use it to create, edit, and delete files, and save your changes directly to GitHub


Editing a post

Also if your posts are not styled as your index.html is then this could mean that there is something wrong with your layouts.

3
votes

The provided themes (at least the two I tried, Minimal and Slate) don't have a separate "post" layout, just one "default" layout. Because you've specified layout: post (as instructed by the Jekyll docs), Jekyll is trying to find one and giving up. Remove the layout line entirely and it will fall back, correctly, to the default style. You don't have to create or edit a layout.

2
votes

Note that starting Dec. 2016, you can work with markdown page only (no yaml needed then)

  • All Markdown files are now rendered by GitHub Pages, saving you from needing to add YAML front matter (the metadata at the top of the file separated by ---s) to each file.

  • We'll use your README file as the site's index if you don't have an index.md (or index.html), not dissimilar from when you browse to a repository on GitHub.

  • If a given file doesn't have a layout specified, we'll assign one based on its context. For example, pages will automatically get the page layout, or the default layout, if the page layout doesn't exist.

  • If your page doesn't have an explicit title, and the file begins with an H1, H2, or H3, we'll use that heading as the page's title, which appears in places like browser tabs.

1
votes

If you want Jekyll to generate you site on Github Pages, you will need to add layouts and maybe _config.yml file.

Have a look a the Jekyll site template here and read the Jekyll documentation.