Blogdown: как обрабатывать пути к изображениям? - PullRequest
0 голосов
/ 10 мая 2019

У меня есть блог, размещенный на 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 Выполнение остановлен

** Правильный ли способ указать полный путь? Я спрашиваю об этом, потому что HTML, представленный для моих изображений, немного грязный по сравнению с HTML, созданным для графиков, созданных с кодом R.

Я сравнил 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."
...