在Blogger中使用相关链接 [英] Using relative links in Blogger

查看:119
本文介绍了在Blogger中使用相关链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用博客

当我需要提及一个链接时,在我的博客的帖子中,链接实际上是我自己的博客帖子的链接,我提到它的其他部分带有

的一个>标签

<$ p $如果我改变了我的博客名称,那么链接将会死亡,

所以我想要的是,我只想提到与我的博客名称的链接

例如



而不是

  www.my_blog_name.blogspot.in/12/2013/how_to_do.html 



我需要提及它像

  / 12/2013 / how_to_do.html 

即使如果我更改我的博客名称,它也会工作



如果你们有更改博客名称的任何其他解决方案不会影响我的帖子中的链接,请提及它
< Blogger << $ BlogURL $> 标记



< $ BlogURL $> 指向您博客的网址。



用法:A对于家庭链接有很好的价值,或者返回档案模板中的当前链接,例如

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



也可以用作基础href,以使相关链接在主页面和归档页面中均可工作单独的目录。



所以你可以做
$ b

< a href =< ; $ BlogURL $> /12/2013/how_to_do.html>您的网址< / a>





Blogger制作相关链接(链接类似于< a
href =archives / archive.html>
是相对的,像< a
href =http://www.domain.com/archives/archive.html>
这样的链接是绝对的
链接)比平常更难管理,因为大多数人
将其档案保存在与主页不同的目录中。如果
在帖子中链接到images / mypic.jpg,那么当该帖子被
存档时,链接将指向archives / images / mypic.jpg,因此
不是被发现。如果将相对链接放在
主模板中,也会发生同样的情况,因为存档页面也是从
主模板创建的。不要担心,有两个简单的修复。



修复之一是使用base href标记来告诉浏览器每一个
相对url开始路径到您的主目录。在您的主
模板的< head> 部分中,包含标记< base
href =< ; $ BlogURL $>中>
。如果您有独立的归档索引页面样式
的归档,请在归档
模板的部分中包含一个基础href。下次您发布或发布&发布时,所有
的相关链接将从您拥有
主页的目录开始,无论它们位于该目录中,还是位于您的存档
目录中。请确保您记得在您的博客中更改您的
设置中的博客URL!



第二个修复程序是使用基于服务器的路径,而不是相对
路径:服务器根路径以斜杠开始,并列出服务器根目录中的所有
目录。例如,如果
您的主页是 www.example.com/index.html ,并且您的存档是 www中的
.example.com / archives / archive.html
,然后以服务器为根的链接到
,档案将是< a href =/ archives / archive。 html> ,以及
服务器根目录的链接到 www.example.com/images / 中的图片将看起来
< img src =/ images / image.jpg> 。但是,如果您的主页位于
www.freehost.com/bunch12/~username/blog/blogger.html 中,则一个基于服务器的
链接将开始 / bunch12 /〜用户名/博客/ ,并且使用基础href标记
将会变得更加容易(一旦您习惯了它)。

来源

i am using blogger

when i need to mention a link , in a post of my blog and the link is actually a link of my own blog post , i am mentioning itside < a >tag with

www.my_blog_name.blogspot.in/12/2013/how_to_do.html

if i changed my blog name then the link will be dead ,

So what i want is , i just want mention the link with out my blog name

for example

instead of

www.my_blog_name.blogspot.in/12/2013/how_to_do.html

i need to mention it like

/12/2013/how_to_do.html

so even though if i changed my blog name it will work

if you guys having anyother solution for changing blog name does't affects links inside my posts plz mention it

解决方案

Blogger has <$BlogURL$> tag

<$BlogURL$> points to the URL of your blog.

Usage: A good value for a "home" link, or the "back to current" link in an archive template, e.g.

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

Can also be used as a base href, to make relative links work in both the main page and in archive pages in a separate directory.

So you can do

<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

这篇关于在Blogger中使用相关链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆