Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking to another post in blogdown

Tags:

r

blogdown

Suppose I have an older post in contents/post/2019-04-29-old-post.Rmd and I want to link to it from a new rmarkdown post. Is there any way to do it without using the hardcoded url of the live site (so that I don't have to change all these cross links when the url of my site changes)?

Right now I do this:

In the [previous post](https://my.si.te/2019/04/29/old-post.html) we covered...

Is there a way to just identify the old post in some way (maybe the Rmd file name) and have blogdown/hugo generate the correct url?

like image 699
Jan Hlavacek Avatar asked May 01 '19 01:05

Jan Hlavacek


1 Answers

If you have set your base URL correctly in config.toml like this:

baseurl = "https://my.si.te/"
languageCode = "en-us"
title = "A Hugo website"
theme = "hugo-lithium"
googleAnalytics = ""

and also have set the [permalinks] setting (also in config.toml):

[permalinks]
    post = "/:year/:month/:day/:slug/"

Then the base URL becomes the root folder, so you can link like this:

In the [previous post](/2019/04/29/old-post/) we covered...

the generic form being

In the [previous post](/:year/:month/:day/:slug/) we covered...

Based on the [permalinks] option.

like image 160
Wil Avatar answered Oct 01 '22 01:10

Wil