鹈鹕图像链接断开

鹈鹕图像链接断开

本文介绍了当通过“类别"查看文章时,鹈鹕图像链接断开.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定我缺少明显的东西.我通过内容文件夹中的文件夹名称定义类别.如果在查看页面时单击content,我会看到文件夹名称(例如categ1,categ2)加'misc',就可以了.当我单击categ1时,我看到了一篇完整的文章,但是图像链接现在都坏了.

I am sure I'm missing something obvious. I'm defining Categories through folder names inside the content folder. If I click content while viewing a page, I see folder names (e.g. categ1, categ2) plus 'misc', that's fine. When I click categ1, I see one complete article but the image links are now all broken.

localhost:8000/category/categ1.html

我想看到的只是该类别中可点击的文章列表.或至少没有损坏的链接.

What I would like to see is just a click-able list of articles in that category. Or at the very least, not broken links.

(如果我尝试使用标签,也会有类似的行为,但是一次只能做一件事...)

(I have similar behavior if I try to use tags, but one thing at a time...)

.rst文件中没有类别行.

除了名称,时区等之外,我还在配置中使用它们.

Besides name, timezone etc. I am using these in my configuration.

更新:图像位于内容"的图像"文件夹中.我也将Images文件夹的副本放在categ1中,但没有帮助.

UPDATE: Images are in the Images folder in Content. I've also put a copy of Images folder in categ1, but no help.

THEME = 'nmnlist'

PATH = 'content'

# ARTICLE_PATHS = ['articles']    # have tried this also

STATIC_PATHS = ['images', 'pdfs']

RELATIVE_URLS = True  # have tried False also

PLUGINS = ["render_math"]

推荐答案

听起来像图像URL相对可能是一个问题.

It sounds like this might be a problem with image URLs being relative.

问题

在这种情况下,假设您在localhost:8000/mypage.html中生成了一个content/mypage.md中的Markdown页面,并且该页面具有对图像的(有效)引用:

If this is the case, suppose you have a Markdown page in content/mypage.md that is generated into localhost:8000/mypage.html, and it has a (working) reference to an image:

![Alt text](content/myimage.png)

呈现到html中的

<img src="content/myimage.png" />

并指向localhost:8000/content/myimage.png.但是,如果您随后尝试对类别页面将相同的Markdown处理为HTML,则会呈现相同的图像Markdown:

and points to localhost:8000/content/myimage.png. However, if you then try and process that same Markdown into HTML for a categories page, it will render the same image markdown:

![Alt text](content/myimage.png)

插入相同的html:

<img src="content/myimage.png" />

,但是由于它位于localhost:8000/categories/mycategory.html的类别"页面上,所以此相对图像URL现在指向localhost:8000/categories/content/myimage.png,并且图像在类别"和标记"页面上已损坏.

but since this is on the categories page at localhost:8000/categories/mycategory.html, this relative image URL now points to localhost:8000/categories/content/myimage.png and the image is broken on categories and tags pages.

解决方案

解决方案很简单:一个/.在Markdown中使用对图像的绝对引用,方法是在它们前面加上/:而不是使用content/myimage.png,而使用/content/myimage.png:

The solution is simple: one /. Use absolute references to images in your Markdown by prefixing them with a /: instead of using content/myimage.png, use /content/myimage.png:

![Alt text](/content/myimage.png)

无论在哪个页面上,都将始终在localhost:8000/content/myimage.png处渲染图像.

That will always render the image at localhost:8000/content/myimage.png, regardless of what page it is on.

这篇关于当通过“类别"查看文章时,鹈鹕图像链接断开.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 05:12