Search code examples
jekyll

Wordpress export to Jekyll - cannot figure out index link to posts


I used WordPress to Jekyll Exporter Wordpress export to Jekyll.

I have uploaded files to mygithubname.Github.io repository.

I put the following code on index.md.

## Welcome to {{ site.url }}

### Posts

<ul>
  {% for post in site.posts %}
    <li>
      <a href="{{ post.url }}">{{ post.title }}</a>
    </li>
  {% endfor %}
</ul>

This shows a nice list of posts by their name. However, the link that is generated is like https://mygithubname.github.io/?p=856 and it doesn't actually link to anything.

I believe that Jekyll post urls should have post name so why is it generating the ?p=856 url ?

The export generated post page variables are like following:

---
id: 247
title: Always remember to start Python Virtualenv
date: 2016-01-29T03:56:06+00:00
author: mygithubname
layout: post
guid: http://mygithubname.github.io/?p=247
permalink: /?p=247
categories:
  - django
  - Python
---

How do I get Jekyll to generate links that work?


Solution

  • The reason you are getting URLs like /?p=247 is because your posts have permalink defined in the front matter in each of your markdown files. If you delete the permalink attribute, you will allow jekyll to auto generate the URL for each post.

    If you would like some code samples, here is a simple jekyll based website, minima, that shows what happens when you omit permalink from the front matter of markdown (i.e. *.md) files.

    Here is a specific post example showing how jekyll assigns URLs to posts.

    Source code of one post: https://github.com/jekyll/minima/blob/master/_posts/2016-05-19-super-short-article.md

    Rendered post: https://jekyll.github.io/minima/misc/2016/05/19/super-short-article.html