代码之家  ›  专栏  ›  技术社区  ›  Gregory

如何从创建雨果学术文章的图像预览。Rmd?

  •  4
  • Gregory  · 技术社区  · 7 年前

    我正试图添加一个图像预览后使用雨果学术和编译。Rmd和blogdown,我不知道在YAML序言中该做什么。

    一些没有提供解决方案的相关帖子包括:

    - Include image preview in blogdown (.Rmd yaml header)

    - How to add feature or thumbnail image for post in .Rmd file

    ---
    [header]
    image="path"
    ---
    

    根据 blogdown book image: "path" 显然被忽略,因为任何字符串都可以替换为“path”,而不会改变行为。至少bookdown在public/img/headers中将图像放在了正确的位置。

    3 回复  |  直到 7 年前
        1
  •  3
  •   Sébastien Rochette    7 年前

    这是怎么回事 [] 在一个 toml 可以在中不使用括号添加标题 yaml
    就你而言 学术的 主题,a YAML 标头需要按如下方式编写(请记住,路径是相对于 static/img/ 文件夹):

    ---
    title: "Posts"
    date: 2017-01-01
    math: false
    highlight: false
    header:
      image: ""
      caption: ""
    ---
    

    getting-started 文件 exampleSite 保存为 Rmd 文件将包含以下内容 亚马尔 标题(我测试了它,它可以工作):

    ---
    date: 2016-04-20
    lastmod: 2017-09-03
    draft: false
    tags: ["academic", "hugo"]
    title: "Getting started with the Academic framework for Hugo"
    math: true
    summary: "Create a beautifully simple personal or academic website in under 10 minutes."
    header:
      image: "headers/getting-started.png"
      caption: "Image credit: [**Academic**](https://github.com/gcushen/hugo-academic/)"
    ---
    
        2
  •  1
  •   Matthew J. Oldach    5 年前

    我也有同样的问题 雨果学院 主题和上述解决方案不适合我。

    这是我的 YAML 我的标题 .Rmd 文件和我的 pizza.jpg 在中 static/img/ 文件夹

    enter image description here

    如您所见,没有显示预览图像:

    enter image description here

    然而,你 查看此图像 在内部 这个 项目 :

    enter image description here

    如何正确获取图像 预览 使用 学术的 主题

    你可以看看我的 repo ( https://github.com/moldach/moldach.github.com )如果你想。。。但为了子孙后代,我试图在这里提供足够的信息,因为这将在未来发生变化。

    :图像预览对象旁边的项目 项目之所以有效,是因为它们是指向中外部网站的链接 .md .Rmd

    enter image description here

    解决了的:

    好的,错误是你需要 preview_only: (不是 image_preview: )并注意适当的缩进(2个空格键点击) image: .

    确保您拥有 Rmd 和预览图像(命名为 featured.jpg/featured.png 坐在 project 它是一个文件夹 这样地:

    enter image description here

    可能最好将粘贴复制为 亚马尔 在适当的间距下很挑剔:

    ---
    title: 'Shiny Dev and Software Release Cycles and Rayshader, Oh My!'
    summary: ''
    author: "Matthew J. Oldach"
    tags: []
    categories: []
    date: "2019-11-23"
    featured: false
    draft: false
    
    # Featured image
    # To use, add an image named `featured.jpg/png` to your page's folder.
    # Focal points: Smart, Center, TopLeft, Top, TopRight, Left, Right, BottomLeft, Bottom, BottomRight.
    image:
      caption: ""
      focal_point: ""
      preview_only: true
    
    # Projects (optional).
    #   Associate this post with one or more of your projects.
    #   Simply enter your project's folder or file name without extension.
    #   E.g. `projects = ["internal-project"]` references `content/project/deep-learning/index.md`.
    #   Otherwise, set `projects = []`.
    projects: []
    ---
    
        3
  •  0
  •   Franky    4 年前

    关于你的问题,对我来说唯一有效的事情是重命名。rmd文件作为索引。rmd。解决了我所有的问题;-)