Linking to another post in blogdown
Asked Answered
A

1

8

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?

Archaeology answered 1/5, 2019 at 1:29 Comment(0)
A
7

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.

Available answered 2/5, 2019 at 12:24 Comment(1)
What if the file is stored just within the contents directory and not posts?Olympie

© 2022 - 2025 — McMap. All rights reserved.