【问题标题】:Include image preview in blogdown (.Rmd yaml header)在 blogdown 中包含图像预览(.Rmd yaml 标头)
【发布时间】:2018-03-13 11:14:29
【问题描述】:

我尝试了几种方法,但到目前为止都没有奏效。我想在我的主博客页面上包含用 R markdown (.Rmd) 编写的博客文章的图像预览,其中通常显示许多文章和项目。我可以使用从 Hugo academic-theme here 获取的以下代码使其在普通降价 (.md) 中工作。

+++
# Optional image to display on homepage (relative to `static/img/` folder).
image_preview = "bubbles.jpg"
+++

结果将如here 所示(参见Projects 部分)。

但是,我不知道如何将其翻译为我博客文章中的.Rmd yaml。我可以在顶部使用下面的图片,但由于我使用的是toc 目录选项,因此该图片仅在toc 之后显示,因此不会出现在主页的帖子预览中。

---
title: some title
author: some author
date: 'some date'
slug: some-slug
categories:
  - some category
tags:
  - some-tag
output:
  blogdown::html_page:
    toc: true
    number_sections: true
    toc_depth: 2
---

![](/post/img/some_img.png)

理想情况下,图像仅显示在主页的预览中,而不是实际的博客文章中(目的是用视觉上吸引人的图像“吸引”读者到实际内容)但如果不可能,否则我也是如果图像显示在实际帖子的顶部,只要它显示在主页的预览中就可以了。

【问题讨论】:

    标签: r hugo blogdown


    【解决方案1】:

    如果image_preview 参数与md 文档一起使用,它也应该与Rmd 一起使用,前提是您使用: 的语法我猜:

    ---
    title: some title
    author: some author
    date: 'some date'
    slug: some-slug
    categories:
      - some category
    tags:
      - some-tag
    output:
      blogdown::html_page:
        toc: true
        number_sections: true
        toc_depth: 2
    image_preview: 'bubbles.jpg'
    ---
    

    【讨论】:

    • 谢谢。 : 让一切变得不同......有时很容易。
    猜你喜欢
    • 1970-01-01
    • 2015-11-14
    • 1970-01-01
    • 2021-05-20
    • 2021-12-24
    • 2021-06-26
    • 2019-09-30
    • 2023-03-29
    • 2018-05-02
    相关资源
    最近更新 更多