Blogdown:如何处理图片路径?

时间:2019-05-10 19:49:57

标签: r r-markdown blogdown

我有一个托管在Netlify上的博客,它从我的Github存储库中调用文件:

https://github.com/OmarGonD/omargonzalesdiaz

网络:http://omargonzalesdiaz.rbind.io/blog/1/01/01/sumo-emailmarketing/

在项目的结构中,我将帖子的图像放在img/posts子文件夹中。

但是,当使用Rmd文件中的图像时,我需要调用完整路径,如下所示:

```{r, echo=FALSE, fig.cap="", out.width = '100%', fig.align='center'}
knitr::include_graphics("D:/omargonzalesdiaz/static/img/posts/sumo/rule_5_SUCCESS_C.jpg")
```

如果我这样做:

```{r, echo=FALSE, fig.cap="", out.width = '100%', fig.align='center'}
knitr::include_graphics("/img/posts/sumo/custom_email_address.jpg")
```

我得到:

  

在资源中找不到文件/img/posts/sumo/custom_email_address.jpg   路径错误:pandoc文档转换失败,错误为99执行   停止

**放置完整路径的正确方法是吗?我之所以这样问,是因为与通过R代码生成的绘图生成的html相比,为我的图像渲染的html有点混乱。

我已经将为我的博客呈现的html与其他博客进行了比较,我发现当其他博客呈现其图像时,它们会生成:

<img src="/post/2019-03-06-lots-of-zeros_files/figure-html/unnamed-chunk-5-1.png" width="672">

这是因为它们只是渲染用R代码生成的图?

我问这个是因为我图片的html看起来有点乱:

<img src="data:image/jpeg;base64,/9j/4RD3RXhpZgAATU0AKgAAAAgABwESAAMAAAABA   
   AEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAA/d49f/Z.-C-O-N-T-I-N-O-U"
width="100%" style="display: block; margin: auto;">

config.tolm

baseurl = "/"
title = "omargonzalesdiaz"
theme = "hugo-universal-theme"
languageCode = "es-es"
# Site language. Available translations in the theme's `/i18n` directory.
defaultContentLanguage = "es"
# Enable comments by entering your Disqus shortname
disqusShortname = "omargonzalesdiaz"
# Enable Google Analytics by entering your tracking code
googleAnalytics = "UA-54695178-1"

# Define the number of posts per page
paginate = 10

[menu]

# Main menu

[[menu.main]]
    name = "Inicio"
    url  = "/"
    weight = 1

[[menu.main]]
    name = "Blog"
    url  = "/blog/"
    weight = 2


[[menu.main]]
    name = "contacto"
    url  = "/contacto/"
    weight = 4

# Top bar social links menu

[[menu.topbar]]
    weight = 1
    name = "GitHub"
    url = "https://github.com/devcows/hugo-universal-theme"
    pre = "<i class='fa fa-2x fa-github'></i>"


[[menu.topbar]]
    weight = 3
    name = "Twitter"
    url = "http://twitter.com"
    pre = "<i class='fa fa-2x fa-twitter'></i>"

[[menu.topbar]]
    weight = 4
    name = "Email"
    url = "mailto:oma.gonzales@gmail.com"
    pre = "<i class='fa fa-2x fa-envelope'></i>"

[params]
    viewMorePostLink = "/blog/"
    author = "DevCows"
    defaultKeywords = ["devows", "hugo", "go"]
    defaultDescription = "Site template made by devcows using hugo"

    # Twitter
    twitter = "GoHugoIO"
    twitterImage = "img/twitter-default.png"

    # Google Maps API key (if not set will default to not passing a key.)
    googleMapsApiKey = "AIzaSyCFhtWLJcE30xOAjcbSFi-0fnoVmQZPb1Y"

    # Style options: default (light-blue), blue, green, marsala, pink, red, turquoise, violet
    style = "blue"

    # Since this template is static, the contact form uses www.formspree.io as a
    # proxy. The form makes a POST request to their servers to send the actual
    # email. Visitors can send up to a 1000 emails each month for free.
    #
    # What you need to do for the setup?

    # - set your email address under 'email' below
    # - upload the generated site to your server
    # - send a dummy email yourself to confirm your account
    # - click the confirm link in the email from www.formspree.io
    # - you're done. Happy mailing!
    #
    # Enable the contact form by entering your Formspree.io email
    email = "your@email.com"
    contact_form_ajax = false

    about_us = "<p>Página personal de omargonzalesdiaz.</p>"
    copyright = "Copyright (c) 92019, omargonzalesdiaz; todos los derechos reservados."

    # Format dates with Go's time formatting
    date_format = "January 2, 2006"

    logo = "img/logo.png"
    logo_small = "img/logo-small.png"
    address = """<p><strong>Lima - Perú</strong>""" 


[Permalinks]
    blog = "/blog/:year/:month/:day/:filename/"

# Enable or disable top bar with social icons
[params.topbar]
    enable = true
    text = """<p class="hidden-sm hidden-xs">Contact us on +420 777 555 333 or hello@universal.com.</p>
      <p class="hidden-md hidden-lg"><a href="#" data-animate-hover="pulse"><i class="fa fa-phone"></i></a>
      <a href="#" data-animate-hover="pulse"><i class="fa fa-envelope"></i></a>
      </p>
      """

# Enable and disable widgets for the right sidebar
[params.widgets]
    categories = true
    tags = true
    search = true

[params.carousel]
    enable = true
    # All carousel items are defined in their own files. You can find example items
    # at 'exampleSite/data/carousel'.
    # For more informtion take a look at the README.

[params.features]
    enable = true
    # All features are defined in their own files. You can find example items
    # at 'exampleSite/data/features'.
    # For more informtion take a look at the README.

[params.testimonials]
    enable = false
    # All testimonials are defined in their own files. You can find example items
    # at 'exampleSite/data/testimonials'.
    # For more informtion take a look at the README.
    title = "Testimonials"
    subtitle = "We have worked with many clients and we always like to hear they come out from the cooperation happy and satisfied. Have a look what our clients said about us."

[params.see_more]
    enable = true
    icon = "fa fa-file-code-o"
    title = "Do you want to see more?"
    subtitle = "We have prepared for you more than 40 different HTML pages, including 5 variations of homepage."
    link_url = "#"
    link_text = "Check other homepages"

[params.clients]
    enable = false
    # All clients are defined in their own files. You can find example items
    # at 'exampleSite/data/clients'.
    # For more informtion take a look at the README.
    title = "Our Clientss"
    subtitle = ""

[params.recent_posts]
    enable = true
    title = "Del Blog"
    subtitle = "Entradas más recientes."

0 个答案:

没有答案