Jekyll如何在帖子中显示图像

Cli*_*ram 12 image jekyll

我正在尝试遵循Jekyll文档,并坚持如何显示图像

---
layout: post
title:  "My first post!"
date:   2016-10-20 16:17:57 +0200
categories: jekyll update
regenerate: true
---

This is in the `_posts` directory.
It can be edited then rebuild the site to see the changes.
You can rebuild the site in many different ways, but the most common way is to run `jekyll serve`, which launches a web server and auto-regenerates your site when a file is updated.

![name of the image][{{site.url}}/assets/P6740674.JPG]
Run Code Online (Sandbox Code Playgroud)

我觉得这个问题非常愚蠢,因为它是如此基本,但我找不到任何问题的答案

是否可能是我自己系统上的配置错误.我正在使用apache2,ruby gems等

提前致谢

Kev*_*man 14

如果要使用site.url,则必须向文件中添加url变量_config.yml.更多关于Jekyll文档的信息.

但你可能根本不需要使用它site.url.任何以/斜杠开头的网址都将相对于您网域的顶级网址.所以你可以这样做:

![image tooltip here](/assets/image.jpg)
Run Code Online (Sandbox Code Playgroud)

  • 谢谢你,凯文。它让我理解了这个问题。事实上,我使用了 /assets,它引用了目录 _assets,所以它找不到该文件。当我将其更改为文件夹 /img 时,一切正常 (2认同)

小智 6

我可以看到默认情况下images创建的目录assets。我已经放置了一个图像如下。

assets/images/myimage.jpg 并在帖子中添加以下行。

![My image Name](/assets/images/myimage.jpg)
Run Code Online (Sandbox Code Playgroud)

运行bundle exec jekyll serve看看有没有错误。如果您提到文件位置不匹配,您将在此处看到错误。