其他分享
首页 > 其他分享> > ghost 搭建个人博客网站

ghost 搭建个人博客网站

作者:互联网

开源博客哪家强?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}}


主题构成


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