Skip to content

公共标签

1. 模板嵌套 {echo:include/}

引入同主题下片段,最多嵌套 5 层,禁止 ..

html
{echo:include file="head.htm"/}
{echo:include file="article_nav.htm"/}
{echo:include file="foot.htm"/}
属性说明
file相对路径,如 head.htm

2. 路径与资源

{echo:sitetplpath/}

主题静态资源前缀,值 /theme/{theme}

html
<link href="{echo:sitetplpath/}/css/site.css" rel="stylesheet">

{echo:sitepath/}

站点根路径(根域名部署时为空)。

html
<link rel="icon" href="{echo:sitepath/}/favicon.ico">

{echo:url/}

站内链接;本地 ?site=en 预览时自动带站点参数。

html
<a href="{echo:url path="/"/}">首页</a>
<form method="get" action="{echo:url path="/search"/}">
  <input name="q">
</form>
属性默认说明
path/站内路径

WARNING

action="{echo:url path="/search"}" 若漏写 /},双引号会截断属性导致 404。

{echo:httpurl/} / {echo:pageurl/}

当前完整域名与当前请求 URL。页面规范地址请用下面的 {echo:seohead/},不要把 pageurl 当 canonical。

html
{echo:qrcode string="{echo:pageurl/}"/}

{echo:qrcode/} / {echo:runtime/}

标签说明
{echo:qrcode string="…"/}输出二维码 <img>,请求 /qrcode?text=
{echo:runtime/}渲染耗时(秒,4 位小数)

3. 页面 TDK 与 Head

对标 Pboot {pboot:pagetitle} / {pagekeywords} / {pagedescription}。搜索页 pageKind=search 标题带查询词;留言/地图等仍用站点 TDK。

html
<!-- templets/default/head.htm -->
<html lang="{echo:pagelang/}">
<title>{echo:pagetitle/}</title>
<meta name="keywords" content="{echo:pagekeywords/}">
<meta name="description" content="{echo:pagedescription/}">
{echo:seohead/}
标签说明
{echo:pagetitle/}按页类型组合站点 / 栏目 / 文档 SEO;无属性、转义
{echo:pagelang/}<html lang>zhcnzh-CNenenjaja
{echo:seohead/}绝对 canonical;搜索/部分页 noindex,follow仅首页各语言站 hreflang + x-default(HTML 原文)

导航品牌仍用 {echo:global name="site_title"/}。内页不做 hreflang(各语言站内容不对照)。


4. 定制标签 {echo:label/}

后台「定制标签」按 name 读取。

html
{echo:label name="hotline"/}

5. 条件 {echo:if}

简单真值或比较,可用 {echo:else}

html
{echo:if condition="[field:is_top]"}置顶{echo:else}普通{/echo:if}
{echo:if condition="[field:views] >= 10"}热门{/echo:if}

非完整表达式引擎;块内按当前行 [field:xxx] 取值。


6. 字段修饰

可用于 {echo:field}{echo:channel}、块内 [field:…]

html
[field:title len="30" drophtml="1"/]
[field:published_at style="Y-m-d"/]
{echo:field name="title" len="20"/}

常用:len / lencn / drophtml / substr / style / format / width / height(缩略图 /thumb)/ mark(搜索标红)。

山与海都很美,努力走出去