Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jekyll - link to posts from pages

Tags:

jekyll

A very basic question.

I can not find out how to refer or cite a post in a page.

If this is my post

---
layout: post
title:  "Serve Jekyll Websites with servr and knitr"
categories: [jekyll, rstats]
tags: [knitr, servr, httpuv, websocket]
---

The R package [**servr**](https://github.com/yihui/servr) can be used to set up an HTTP server to serve files under a directory. 

How I am suppose to cite it in my page

---
layout: page
title: About
permalink: /about/
---

You can find out more info in this post 

Could you help me out ?

like image 253
giac Avatar asked Jul 17 '15 16:07

giac


1 Answers

You can do this 2 ways:

  1. Copy-pasting the link generated for your post as a link to it.

    [Check Out My Post!](www.example.com/posts/2015-10-1-name-of-post/)

    This definitely works, but will break/fail when you decide to change link style, or have another permalink, or when you change file names.

  2. The smarter way: Jekyll's built in post_url

    Jekyll has a built in function that allows you to internally link or cite back to posts on your website. Here is the documentation for it, but I will explain the syntax and usage as well.

    Assuming you want to link to a Jekyll post with the filename of 2015-07-17-jekyll-servr-tutorial.md which is located in the _posts folder, the syntax for this would be:

    • {% post_url 2015-07-17-jekyll-servr-tutorial %}
    • {% post_url /tutorials/2015-07-17-jekyll-servr-tutorial %} if you have your posts organized in a subdirectory called tutorials
    • The R Package [servr]({% post_url 2015-07-17-jekyll-servr-tutorial %}) if you want to make hyperlinks.

There is no need to include the file extension name when using this liquid tag function.

Here is additional information and a tutorial on how to use Jekyll post-links that you might find useful as well.

like image 148
matrixanomaly Avatar answered Nov 10 '22 08:11

matrixanomaly