0
votes

Just started jekyll, and I want to display a link to one of my posts on the index.html page. I looked through the documentation and the following code appears to be what I'm suppose to do.

The following is in index.html

<p>......</p>
 [Hello World]({% post_url 2015-01-19-soccer %})
<p>........ </p>

but it simply displays

.....
[Hello World]({% post_url 2015-01-19-soccer %})
.......

what am I doing wrong?

2

2 Answers

2
votes

Since you used a mix of Markdown and HTML, which is causing the markdown processor to ignore anything in between the HTML blocks.

Markdown is also sometimes not processed when you have HTML right above the Markdown. (This is the case for you, since your example shows you have closed off the <p> tags)

There are a few ways around this.

  1. Make sure there is a newline in between any HTML and Markdown, this will not show up as a <br> or a <p> in the final output, but rather ensures that the processor will convert the Markdown correctly.

    So you should have something like this:

    <p>......</p>
    
    [Hello World]({% post_url 2015-01-19-soccer %})
    <p>........ </p>
    

    Notice the extra line there between the first <p></p> and the Markdown.

  2. Use only HTML (this is as answered by user @topleft)

  3. Use only Markdown, since <p> tags are supported.
  4. Try the markdown=1 HTML attribute.

    Markdown processors like Kramdown allow you to add an explicit tag to tell the processor to go through HTML blocks and process any Markdown there. I'm assuming you're using the default (which I believe is Redcarpet) and couldn't find the links on whether this is supported. But you can try this:

     <div id="someDiv" markdown=1>
     [This is a Markdown link that will be parsed](http://www.example.com)
     </div>
    
0
votes

You are using markdown language here, it won't work in html. You need to use that instead :

<a href="{{site.baseurl}}{% post_url 2015-01-01-post %}">Hello World</a>

site.baseurl default is empty you can change it in _config.yml to suit your needs

for instance :

baseurl: "me/blog"