gpt4 book ai didi

html - 在 Blogger 中使用相对链接

转载 作者:可可西里 更新时间:2023-11-01 13:33:06 25 4
gpt4 key购买 nike

最佳答案

Blogger 有 <$BlogURL$>标签

<$BlogURL$>指向您博客的 URL。

用法:“主页”链接的一个很好的值,或者存档模板中的“返回当前”链接,例如

<a href="<$BlogURL$>">home</a>

也可以用作基本 href,使相对链接在主页和单独目录中的存档页面中都有效。

所以你可以这样做

<a href="<$BlogURL$>/12/2013/how_to_do.html">Your URL</a>


Blogger makes relative links (links like <a
href="archives/archive.html">
are relative, links like <a
href="http://www.domain.com/archives/archive.html">
are absolute links) a bit more difficult to manage than usual, because most people keep their archives in a different directory than their main page. If you link to "images/mypic.jpg" in a post, then when that post is archived the link will point to "archives/images/mypic.jpg" and thus not be found. The same thing happens if you put a relative link in your main template, because the archive pages are also created from your main template. Fear not, there are two simple fixes.

Fix one is to use a "base href" tag to tell the browser to start every relative url with the path to your main directory. In your main template, in the <head> section, include the tag <base
href="<$BlogURL$>">
. If you have the separate archive index page style of archives, include a base href in the section of your archive template as well. The next time you publish or post & publish, all your relative links will start from the directory where you have your main page, whether they are in that directory, or in your archives directory. Just be sure you remember to change the Blog URL in your settings if you move your blog!

The second fix is to use server-rooted paths rather than relative paths: a server rooted path starts with a slash, and lists all the directories from the root directory of the server. For example, if your main page was www.example.com/index.html and your archives were in www.example.com/archives/archive.html, then a server-rooted link to the archives would be <a href="/archives/archive.html">, and a server-rooted link to an image in www.example.com/images/ would look like <img src="/images/image.jpg">. However, if your main page is in www.freehost.com/bunch12/~username/blog/blogger.html, a server-rooted link will start /bunch12/~username/blog/, and using a base href tag will be a whole lot easier (once you get used to it).

Source

关于html - 在 Blogger 中使用相对链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24924652/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com