How to hyperlink between different .rmd files in RMarkdown?

Hello! How can I make hyperlinks between different .rmd files. I have several .rmd files on different topics, including media files, which I knit into html files to be published in form of an encyclopedia. I want the reader to be able to click on and switch topics and names of people etc. on the different html pages. Is there a way to do that? I understood the way hyperlinks are created within one document, but what about different documents? Or do I have to put all .rmd files in one and knit it into a single html document to be able to make hyperlinks? This would be problematic as the media files make each document very heavy.
Thanks for any suggestions!

1 Like

I think you have to use externals links and of course they are dependent on the structure of your html files. I use Hugo to build (part of) a website and because of that I know the name of the html page that is published. How do you plan to organize your files?

To be honest, I am not sure yet how to organise it. Im totally new to Markdown. It is supposed to be in some kind of book format. At the moment I just have several .rmd files knitted into html.

They are separate for now and ideally, I want them all to be connected, plus containing hyperlinks that via mouse click link to different headings and topics.

That is possible. As an example I made a small website to show that.
But for a larger website you could look at better solutions as e.g. the blogdown package.
As an example I knitted a main_page document and two sub documents and copied the resulting html files to the following structure:

mainpage
pages / doc1
pages / doc2

You can view the website here .
The following three Rmd files were used:

main_page.Rmd:

---
title: "main page"
author: "LisaG1"
date: "4/20/2020"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## My New Media Website

At the moment it contains:

- [doc1](.\pages\doc1.html) First entry
- [doc2](.\pages\doc2.html) Second entry

A lot more to follow !

doc1.Rmd:

---
title: "doc1 page"
author: "LisaG1"
date: "4/20/2020"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

This is doc1 and it contains a reference to [doc2](.\doc2.html) .

A overview of all entries can be found in the [main document](../main_page.html) .

doc2.Rmd:

---
title: "doc2 page"
author: "LisaG1"
date: "4/20/2020"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

This is doc2 and it contains a reference to [doc1](.\doc1.html).

A overview of all entries can be found in the [main document](../main_page.html).
1 Like

Thanks! will check it out!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.