GHOST CMS - 结构 Structure
Structure
Ghost主题包含静态HTML模板,这些模板使用helper类从站点输出数据,并使用定制的CSS进行样式化
A Ghost theme contains static HTML templates that make use of helpers to output data from your site, and custom CSS for styling.
Structure
Ghost主题的推荐文件结构是:
The recommended file structure for a Ghost theme is:
.
├── /assets
| └── /css
| ├── screen.css
| ├── /fonts
| ├── /images
| ├── /js
├── default.hbs
├── index.hbs [required]
└── post.hbs [required]
└── package.json [required]
一个可选的/partials目录允许您在整个站点中使用部分模板。这允许您在多个模板之间共享HTML块,并减少代码重复。
An optional /partials directory allows you to use partial templates across your site. This allows you to share blocks of HTML between multiple templates and reduce code duplication.
.
├── /assets
├── /css
├── screen.css
├── /fonts
├── /images
├── /js
├── /partials
├── list-post.hbs
├── default.hbs
├── index.hbs [required]
└── post.hbs [required]
└── package.json [required]
Templates模板
需要两个模板文件:index.hbs和post.hbs。所有其他模板都是可选的。我们强烈建议使用default.hbs文件作为你的主题的基本布局。如果对于不同的页面或内容类型有明显不同的布局,则可以使用动态路由配置层,或使用partials来封装主题的公共部分。
Two template files are required: index.hbs and post.hbs. All other templates are optional. We highly recommended using a default.hbs file as a base layout for your theme. If you have significantly different layouts for different pages or content types, you can use the dynamic routing configuration layer, or use partials to encapsulate common parts of your theme.
主题模板是层次化的,因此一个模板可以扩展另一个模板。这可以防止重复基本HTML。以下是一些常用的主题模板及其用途
Theme templates are hierarchical, so one template can extend another template. This prevents base HTML from being repeated. Here are some commonly used theme templates and their uses:
default.hbs
default.hb是一个基本模板,它包含存在于每个页面上的乏味的HTML位,如< HTML >、<head>或<body>,以及所需的{{ghost_head}}和{{ghost_foot}}和任何用于页眉和页脚的HTML。
default.hbs is a base template that contains the boring bits of HTML that exist on every page such as <html>, <head> or <body> as well as the required {{ghost_head}} and {{ghost_foot}} and any HTML for the header and footer.
index.hbs
这是发布列表所需的标准模板。如果您的主题没有标记,也可以使用tag.hbs,author.hbs或index.hbs的模板。index.hbs模板通常扩展默认值。并使用{{#foreach}}帮助器传递一个帖子列表。
This is the standard required template for a list of posts. It is also used if your theme does not have a tag.hbs, author.hbs or index.hbs template. The index.hbs template usually extends default.hbs and is passed a list of posts using the {{#foreach}} helper.
home.hbs
为主页提供特殊内容的可选模板。这个模板只用于渲染/。
An optional template to provide special content for the home page. This template will only be used to render /.
post.hbs
扩展默认值的单个post所需的default.hbs并使用{{#post}}帮助器输出post细节。可以使用post-:slug.hbs创建各个帖子的自定义模板。
The required template for a single post which extends default.hbs and uses the {{#post}} helper to output the post details. Custom templates for individual posts can be created using post-:slug.hbs.
page.hbs
静态页面的可选模板。如果没有指定,那么post。将使用hbs。可以使用page-:slug.hbs创建各个页面的自定义模板。
An optional template for static pages. If this is not specified then post.hbs will be used. Custom templates for individual pages can be created using page-:slug.hbs.
custom-{{template-name}}.hbs
一个可选的自定义模板,可以在管理界面中选择每一篇文章的基础上。它们可以用于文章和页面。
An optional custom templates that can be selected in the admin interface on a per-post basis. They can be used for both posts and pages.
tag.hbs
标签存档页面的可选模板。如果没有指定 index.hbs模板。可以使用tag-:slug创建单个标记的自定义模板。
An optional template for tag archive pages. If not specifed the index.hbs template is used. Custom templates for individual tags can be created using tag-:slug.
author.hbs
一个可选的作者档案页模板。如果没有指定index.hbs模板。可以使用author{{slug}}为个别作者创建自定义模板。
An optional template for author archive pages. If not specified the index.hbs template is used. Custom templates for individual authors can be created using author{{slug}}.
private.hbs
密码保护发布上的密码表单页的可选模板。
An optional template for the password form page on password protected publications.
error.hbs
一个可选的主题模板,用于404或500错误,这些错误不能通过特定于错误或类的模板来处理。如果没有指定,Ghost将使用默认值。
An optional theme template for any 404 or 500 errors that are not otherwise handled by error- or class-specific templates. If one is not specified Ghost will use the default.
error-{{error-class}}xx.hbs
一个可选的主题模板,用于处理属于特定类的错误(例如error-4xx.hbsfor 400级错误)。匹配的错误类模板优先于这两个 error.hbs用于呈现错误的hbs和Ghost默认模板。
An optional theme template for errors belonging to a specific class (e.g. error-4xx.hbsfor 400-level errors). A matching error class template is prioritized over both error.hbs and the Ghost default template for rendering the error.
error-{{error-code}}.hbs
状态代码特定错误的可选主题模板(例如error-404.hbs)。匹配的错误代码模板优先于呈现错误的所有其他错误模板。
An optional theme template for status code-specific errors (e.g. error-404.hbs). A matching error code template is prioritized over all other error templates for rendering the error.
amp.hbs
AMP(加速移动页面)的可选主题模板。如果你的主题没有提供amp.hbs文件,Ghost将使用它的默认值。
An optional theme template for AMP (Accelerated Mobile Pages). If your theme doesn't provide an amp.hbs file, Ghost will use its default.
robots.txt
主题可以包括一个robots.txt,它覆盖Ghost提供的默认robots.txt。
默认主题Casper的开发版本可以用来探索Ghost主题是如何工作的,或者你可以定制Casper并使它成为你自己的!
Themes can include a robots.txt which overrides the default robots.txt provided by Ghost.
The development version of the default theme Casper can be used to explore how Ghost themes work, or you can customise Casper and make it your own!
Helpers
Ghost模板是由HTML和handlebars helper构造的。有几个要求:
为了让Ghost主题发挥作用,您必须使用所需的帮助程序:{{asset}}、{{body_class}}、{{post_class}}、{{ghost_head}}、{{ghost_foot}}。
有关特定Handlebars助手的详细信息,请参阅助手的完整列表。
Ghost templates are constructed from HTML and handlebars helpers. There are a few requirements:
In order for a Ghost theme to work, you must make use of the required helpers: {{asset}}, {{body_class}}, {{post_class}}, {{ghost_head}}, {{ghost_foot}}.
See the full list of helpers for more detailed information about specific Handlebars helpers.
Contexts
Ghost主题中的每个页面都属于由URL确定的上下文。上下文将决定使用什么模板,什么数据可用,以及{{body_class}} helper将输出什么。
Each page in a Ghost theme belongs to a context which is determined by the URL. The context will decide what template will be used, what data is available and what is output by the {{body_class}} helper.
Styling
在构建主题时,一定要考虑类和id的范围,以避免主样式和post样式之间的冲突。id是自动为标题生成的,并在文章中使用,所以最好将内容限定在页面的特定部分。例如:#themename-my-id优先于#my-id。
When building themes it is important to consider the scope of classes and IDs to avoid clashes between your main styling and your post styling. IDs are automatically generated for headings and used inside a post, so it's best practice to scope things to a particular part of the page. For example: #themename-my-id is preferrable to #my-id.
Development mode
建议使用本地安装使用开发模式构建自定义主题-请参阅本地安装指南,以便开始您自己的本地安装进行开发。
在生产模式中,模板文件由服务器加载和缓存。要反映hbs文件中的任何更改,请使用ghost restart命令。
当你上传你的主题到Ghost管理时,Ghost将自动检查致命错误。对于开发期间的完整验证报告,请使用GScan工具。
It is recommended to use a local install to build a custom theme using development mode – review the local install guide to get started with your own local install for development.
In production mode, template files are loaded and cached by the server. For any changes in a hbs file to be reflected, use the ghost restart command.
Ghost will automatically check for fatal errors when you upload your theme into Ghost admin. For a full validation report during development, use the GScan tool.
Summary
现在,您已经对Ghost主题的结构和一些最常见模板的概述有了坚实的理解。在深入研究上下文、帮助程序和其他特性的细节之前,下一步是获得包package.json的概述。
You now have a solid understanding of how a Ghost theme is structured and an overview of some of the most common templates. Before diving into the specifics of contexts, helpers and additional features, the next step is to get an overview of the package.json file.
GHOST CMS - 结构 Structure的更多相关文章
- amazeui学习笔记二(进阶开发1)--项目结构structure
amazeui学习笔记二(进阶开发1)--项目结构structure 一.总结 1.项目结构:是说的amazeui在github上面的项目结构,二次开发amazeui用 二.项目结构structure ...
- GHOST CMS -上下文概述 Context Overview
Context Overview上下文概述 Each page in a Ghost theme belongs to a context, which determines which templa ...
- GHOST CMS - Ghost Handlebars主题 Ghost Handlebars Themes
Ghost Handlebars主题 Ghost Handlebars Themes Ghost主题层被设计为让开发人员和设计人员能够灵活地构建由Ghost平台支持的自定义发布 The Ghost t ...
- GHOST CMS - 创建自定义主页 Creating a custom home page
创建自定义主页 Creating a custom home page 为你的网站创建一个自定义的主页是一个让你从人群中脱颖而出的好方法,并把你自己独特的印记存放在你的网上.本教程向您展示了如何在Gh ...
- GHOST CMS - Package.json
Package.json The package.json file is a set of meta data about a theme. package.json 文件是一组关于主题的元数据. ...
- GHOST CMS - 配置 Config
Config For self-hosted Ghost users, a custom configuration file can be used to override Ghost's defa ...
- 循环/loop 结构/structure
1.Shell loop 2.C++/CPlusPlus ①.std::for_each ②.for loop ③.Iterator library 3.Python Loop ①.Python.or ...
- C#编程利器之二:结构与枚举(Structure and enumeration)【转】
C#编程利器之二:结构与枚举(Structure and enumeration) 在上一篇文章中,介绍了类如何封装程序中的对象.而实际中,出了类可以封装对象外,结构和枚举也可以封装一些对象,本文将着 ...
- C++程序结构---1
C++ 基础教程Beta 版 原作:Juan Soulié 翻译:Jing Xu (aqua) 英文原版 本教程根据Juan Soulie的英文版C++教程翻译并改编. 本版为最新校对版,尚未定稿.如 ...
随机推荐
- 2019-11-6:ubuntu 18安装tomcat 9.0
1,下载tomcat,选择自己想要的版本下载即可 下载官网:http://tomcat.apache.org/ 2,将下载的源码放到自己需要的位置,解压,我新建了一个tomcat目录 sudo mkd ...
- 封装Ajax和跨域
目录 引言 封装ajax 案例:使用自封装ajax 案例:动态加载瀑布流 跨域 引言 对于Ajax现在相信大家已经不会陌生了,无论是原生的XMLHttpRequest方式发送还是通过jQuery框架中 ...
- kube-apiserver 集群服务安装
目录 创建 kube-apiserver 证书 生成证书和私钥 创建加密配置文件 创建审计策略文件 分发 kube-apiserver 二进制文件 创建后续访问 metrics-server 使用的证 ...
- shell介绍、命令历史、命令补全和别名、通配符、输入输出重定向
第5周第5次课(4月20日) 课程内容: 8.1 shell介绍8.2 命令历史8.3 命令补全和别名8.4 通配符8.5 输入输出重定向 8.1 shell介绍 使用yum+管道方式查看zsh和ks ...
- c语言l博客作业09
问题 答案 这个作业属于那个课程 C语言程序设计II 这个作业要求在哪里 https://edu.cnblogs.com/campus/zswxy/CST2019-2/homework/8655 我在 ...
- hashtable基础
- Spring Boot和Feign中使用Java 8时间日期API(LocalDate等)的序列化问题【转】
Spring Boot和Feign中使用Java 8时间日期API(LocalDate等)的序列化问题 http://blog.didispace.com/Spring-Boot-And-Feign- ...
- Netty学习——通过websocket编程实现基于长连接的双攻的通信
Netty学习(一)基于长连接的双攻的通信,通过websocket编程实现 效果图,客户端和服务器端建立起长连接,客户端发送请求,服务器端响应 但是目前缺少心跳,如果两个建立起来的连接,一个断网之后, ...
- PAT乙级练习(1001)
1001 害死人不偿命的(3n+1)猜想 卡拉兹(Callatz)猜想: 对任何一个正整数 n,如果它是偶数,那么把它砍掉一半:如果它是奇数,那么把 (3n + 1) 砍掉一半.这样一直反复砍下去,最 ...
- 基于vue的cropper插件编写分享
目录 简介 实现功能 实现原理 github地址:https://github.com/yinzhida/vue-crop git clone: https://github.com/yinzhida ...