ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

ghost 搭建个人博客网站

2021-02-08 02:32:28  阅读:547  来源: 互联网

标签:ghost Ghost Ctrl author 博客 blog post hbs 搭建


开源博客哪家强?Ghost 一定值得一试。Ghost 已经算得上是老牌开源博客系统,如今发布的 Ghost 3 更是其史上包含最多更新内容的版本。Ghost 3 拥有更漂亮的前端设计和易用的后台管理系统,并支持使用 Github Actions 连续部署主题和管理付费订阅内容。如果你需要搭建个人博客或者是付费内容发布系统,那么 Ghost 一定是最值得考虑的选择

https://www.ghostchina.com/

 https://github.com/TryGhost/Ghost/releases

npm install ghost-cli -g

 

修改端口

打开默认的 config.development.json 配置如下

接下来,修改配置文件中默认端口 port 为 8080,原因是线上环境仅支持 8080 端口访问。然后修改 host 为公网可访问的 0.0.0.0。实际上,在真正部署时无需修改默认配置,当然这里也学会了修改自定义配置的方法

 

 

 

Ghost 快捷手册

安装/设置

最新版本 下载
安装指令 npm install --production
启动 Ghost npm start
停止 Ghost Ctrl+C

文件路径

配置文件 /config.js
主题 /content/themes
插件 /content/apps
图片 /content/images
导航(默认) /core/server/helpers/tpl/navigation.hbs
分页(默认) core/server/helpers/tpl/pagination.hbs

MarkDown/快捷键

Save - Ctrl + S
Bold **text** Ctrl / Cmd + B
Emphasize __text__ Ctrl / Cmd + I
Inline Code `code` Cmd + K / Ctrl + Shift + K
Link [title](http://) Ctrl + Shift + L
Image ![alt](http://) Ctrl + Shift + I
List * item Ctrl + L
H1 # Heading Ctrl + Alt + 1
H2 ## Heading Ctrl + Alt + 2
H3 ### Heading Ctrl + Alt + 3
Select Word   Ctrl + Alt + W
Uppercase - Ctrl + U
Lowercase - Ctrl + Shift + U
Titlecase - Ctrl + Alt + Shift + U
Insert Current Date - Ctrl + Shift + 1

相关资源


Default.hbs

default.hbs 文件中可以用到的 Handlebars 指令

Head

{{meta_title}}
{{meta_description}}
{{ghost_head}}

Body

{{body_class}}
{{{body}}}

Footer

{{@blog.title}}
{{@blog.url}}/rss/
{{ghost_foot}}


主题构成

  • /assets
    • /css
      • screen.css
      • post.css
    • /fonts
    • /images
    • /js
    • /partials
      • pagination.hbs
  • default.hbs
  • index.hbs [必须]
  • post.hbs [必须]
  • page.hbs [可选]
  • tag.hbs [可选]
  • package.json

Handlebars

注释

{{! 'A Comment' }}

HTML 转义

{{content}}

if 指令

{{#if author.website}}
{{else}}
{{/if}}

unless 指令

{{#unless author.website}}
{{/unless}}

foreach 指令

{{#foreach posts}}
{{/foreach}}

块表达式

{{#author}}
{{/author}}


Index.hbs

index.hbs 文件中可以使用的 Handlebars 指令

加载父模板 default.hbs

{{!< default}}

Header

{{#if @blog.cover}}
{{@blog.cover}}
{{/if}}

{{#if @blog.logo}}
{{@blog.logo}}
{{/if}}
{{@blog.title}}
{{@blog.description}}

文章

{{#foreach posts}}
{{/foreach}}
{{post_class}}
{{date format='YYYY-MM-DD'}}
{{date published_at format="MMMM DD, YYYY"}}
{{date published_at timeago="true"}}

{{#if tags}}
{{tags}}
{{tags separator=" | "}}
{{/if}}

{{excerpt}}
{{excerpt characters="140"}}
{{content}}
{{content words="100"}}

分页

{{pagination}}


API 概览

  1. @blog.title
  2. @blog.url
  3. @blog.logo
  4. @blog.description
  5. meta_title
  6. meta_description
  7. body
  8. body_class
  9. ghost_head
  10. ghost_foot
  11. pagination
    • next
    • page
    • pages
    • page_url prev
    • page_url next
    • prev
  12. post_class
  13. post, posts
  14. author
    • name
    • website
    • bio
    • cover
    • email
    • image
  15. excerpt [characters][words]
  16. content [characters][words]
  17. url [absolute]
  18. tags [separator]
    • name
  19. date [format][timeago]
  20. id
  21. published_at

Post.hbs

post.hbs 文件中可以使用的 Handlebars 指令

加载父模板 default.hbs

{{!< default}}

Header

{{#if @blog.cover}}
{{@blog.cover}}
{{/if}}

{{#if @blog.logo}}
{{@blog.logo}}
{{/if}}

{{@blog.title}}
{{@blog.description}}
{{date published_at timeago="true"}}

文章

{{post_class}}
{{#if}}
{{else}}
{{/if}}

{{#post}}
{{/post}}
{{url}}
{{{title}}}
{{date format='YYYY-MM-DD'}}
{{date published_at format="MMMM DD, YYYY"}}
{{#if tags}} {{tags}}
{{tags separator=" | "}}
{{/if}}
{{content}}

作者信息

{{#author}}
{{/author}}

{{#if author}}
{{/if}}

{{author.name}}
{{author.bio}}
{{author.email}
{{author.website}}
{{author.image}}
{{author.cover}}

标签:ghost,Ghost,Ctrl,author,博客,blog,post,hbs,搭建
来源: https://www.cnblogs.com/lzjloveit/p/14387439.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有