在站点根文件夹内的文件夹中定义HTML根 [英] Defining root of HTML in a folder within the site root folder
问题描述
我想要一个包含一组新html文件的新文件夹。其中的所有图像格式为 src =image.png
和 image.png
位于根文件夹。但是,当你把HTML文件放在一个新文件夹中时,它找不到图像。你必须以格式 src =../根文件夹/ folder / image.png
来使它工作。这意味着很多粘贴。我试过在文件夹内放置 image.png
但没有改变。 使用 > < base>
元素。它允许您指定网页中所有相对网址的网址。
例如
<!DOCTYPE html>
< html>
< head>
< meta charset =utf-8>
< title>这是< base>的一个例子。元素< /标题>
< base href =http://www.example.com/news/index.html>
< / head>
< body>
< p>访问< a href =archives.html>存档< / a>。< / p>
< / body>
< / html>
本例中的链接将链接到http://www.example.com/news/archives.html 。
For您,基本网址可能与< base href =http://www.yoursite.com/>
一样简单。这将使图像具体化为 src =image.png
解析为http://www.yoursite.com/image.png
另见 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
I want to have a new folder containing a set of new html files. All the images inside it are in the format src="image.png"
and image.png
is located in the root folder. But when you put the HTML file in a new folder it can't find the image. You have to have it in the format src="../root folder/folder/image.png"
to make it work. Which would mean a lot of pasting. I have tried putting image.png
inside the folder but no change.
Use the <base>
element. It allows you to specify a URL for all relative URLs in a page.
For example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>This is an example for the <base> element</title>
<base href="http://www.example.com/news/index.html">
</head>
<body>
<p>Visit the <a href="archives.html">archives</a>.</p>
</body>
</html>
The link in the this example would be a link to "http://www.example.com/news/archives.html".
For you, the base URL may be something as simple as <base href="http://www.yoursite.com/">
. This would make images specificed as src="image.png"
resolve as "http://www.yoursite.com/image.png"
See also https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
这篇关于在站点根文件夹内的文件夹中定义HTML根的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!