Tanga94
Tanga94

Reputation: 837

How to include an image in the header of a blogdown post

I am using the Academic Hugo Theme to build a website in R.

I have created a blog post using an RMarkdown file. If I'm interested in inserting a picture in the header of the post, which path should I save it to within the folder structure and how do I include it in my YAML/markdown code?

My YAML is as follows:

---
title: "Do oil prices explain the South African Rand's Performance?"
author: "Tangeni Shatiwa"
date: 2020-06-11T21:13:14-05:00
tags: ["South African Rand", "Brent Crude Oil", "Global Uncertainty","Non-Linear Spline Regression"]
output: html_document
---

Ideally, I would like an image to appear underneath the title before the content of my post begins

TIA!

Upvotes: 0

Views: 547

Answers (1)

user13653858
user13653858

Reputation:

It's possible! You can include a file named featured.jpg (or featured.png) in the folder with your post markdown file.

Then you only adapt the YAML header:

---
title: "Do oil prices explain the South African Rand's Performance?"
author: "Tangeni Shatiwa"
date: 2020-06-11T21:13:14-05:00
tags: ["South African Rand", "Brent Crude Oil", "Global Uncertainty","Non-Linear Spline Regression"]
output: html_document
image:
  caption: "Oil can"
  focal_point: "Center"
  alt_text: This is a picture of oil can.
---

It's called featured image and you can read more options in the documentation. It looks e.g. like this post (see source code).

Upvotes: 2

Related Questions