Web Notes
2016.08.20
Using Liquid in Jekyll - Live with Demos
Liquid is a simple template language that Jekyll uses to process pages for your site. With Liquid you can output complex contents without additional plugins.
HTML 初学者会经常遇到这样一个问题,如何正确引用一个文件(路径)。比如,怎样在一个 HTML 网页中引用另外一个本地 HTML 网页作为超链接(hyperlink),怎样在一个网页中插入一张图片。如果你在引用文件时(如加入超链接,或者插入图片等),使用了错误的文件路径,就会导致引用失效(无法浏览链接文件,或无法显示插入的图片等)。
为了避免这些错误,正确地引用文件,我们需要学习一下 HTML 路径。
HTML 有两种路径的写法:相对路径和绝对路径。
如果源文件和引用文件在同一个目录里,直接写引用文件名即可。
我们现在建一个源文件 info.html
,在 info.html
里要引用 index.html
文件作为超链接。
假设 info.html
路径是:c:\Inetpub\wwwroot\sites\blabla\info.html
假设 index.html
路径是:c:\Inetpub\wwwroot\sites\blabla\index.html
在 info.html
加入 index.html
超链接的代码应该这样写:
<a href="index.html">index.html</a>
../
表示源文件所在目录的上一级目录,../../
表示源文件所在目录的上上级目录,以此类推。
假设 info.html
路径是:c:\Inetpub\wwwroot\sites\blabla\info.html
假设 index.html
路径是:c:\Inetpub\wwwroot\sites\index.html
在 info.html
加入 index.html
超链接的代码应该这样写:
<a href="../index.html">index.html</a>
假设 info.html
路径是:c:\Inetpub\wwwroot\sites\blabla\info.html
假设 index.html
路径是:c:\Inetpub\wwwroot\index.html
在 info.html
加入 index.html
超链接的代码应该这样写:
<a href="../../index.html">index.html</a>
假设 info.html
路径是:c:\Inetpub\wwwroot\sites\blabla\info.html
假设 index.html
路径是:c:\Inetpub\wwwroot\sites\wowstory\index.html
在 info.html
加入 index.html
超链接的代码应该这样写:
<a href="../wowstory/index.html">index.html</a>
引用下级目录的文件,直接写下级目录文件的路径即可。
假设 info.html
路径是:c:\Inetpub\wwwroot\sites\blabla\info.html
假设 index.html
路径是:c:\Inetpub\wwwroot\sites\blabla\html\index.html
在 info.html
加入 index.html
超链接的代码应该这样写:
<a href="html/index.html">index.html</a>
假设 info.html
路径是:c:\Inetpub\wwwroot\sites\blabla\info.html
假设 index.html
路径是:c:\Inetpub\wwwroot\sites\blabla\html\tutorials\index.html
在 info.html
加入 index.html
超链接的代码应该这样写:
<a href="html/tutorials/index.html">index.html</a>
HTML 绝对路径指带域名的文件的完整路径。
例如我有一个域名 frankindev.com,那么这个域名就是网站的根目录。
假设在根目录下放了一个文件 index.html
,这个文件的绝对路径就是: https://frankindev.com/index.html
。
假设在根目录下建了一个目录叫 html_tutorials
,然后在该目录下放了一个文件 index.html
,这个文件的绝对路径就是 https://frankindev.com/html_tutorials/index.html
。
以上。
Frank Lin
PREV
Web Notes
2016.08.20
Liquid is a simple template language that Jekyll uses to process pages for your site. With Liquid you can output complex contents without additional plugins.
Web Notes
2017.03.18
By default, Jekyll 3 and versions above integrated with Rouge, a pure Ruby syntax highlighter which supports over 100 languages. Since Rouge themes are compatible with Pygments's stylesheets, it’s nice for us to choose a favourable style.
Tools
2022.05.23
It's time to add a new plugin for my Jekyll site to support emojis, with a convenient and consistent way. Also a cheat sheet list for available emojis in GitHub flavoured Markdown documents using JoyPixels icons is presented.
玉真公主别馆苦雨赠卫尉张卿二首
秋坐金张馆,繁阴昼不开。
空烟迷雨色,萧飒望中来。
翳翳昏垫苦,沉沉忧恨催。
清秋何以慰,白酒盈吾杯。
吟咏思管乐,此人已成灰。
独酌聊自勉,谁贵经纶才。
弹剑谢公子,无鱼良可哀。
苦雨思白日,浮云何由卷。
稷契和天人,阴阳乃骄蹇。
秋霖剧倒井,昏雾横绝巘。
欲往咫尺途,遂成山川限。
潈潈奔溜闻,浩浩惊波转。
泥沙塞中途,牛马不可辨。
饥从漂母食,闲缀羽陵简。
园家逢秋蔬,藜藿不满眼。
蟏蛸结思幽,蟋蟀伤褊浅。
厨灶无青烟,刀机生绿藓。
投箸解鹔鹴,换酒醉北堂。
丹徒布衣者,慷慨未可量。
何时黄金盘,一斛荐槟榔。
功成拂衣去,摇曳沧洲傍。