Giter VIP home page Giter VIP logo

itopic.go's Introduction

采用Go语言和Markdown实现的一个简易博客系统[点此查看文章],主要包括以下功能:

  • 按日期、按标签展现文章列表
  • 首页、文章详情页
  • 可生成静态页面,配合Github/Coding Pages可实现简单的博客,https://itopic.org 采用此方案。

功能比较简单,不需要依赖数据库,不需要管理后台,使用者只需要关注文章内容的书写即可,同时写好的文章可直接在Github上查看。

安装Golang

已安装环境可忽略。从golang.org下载并根据实际路径设置环境变量。

export GOROOT=/usr/local/server/go1.8
export GOPATH=/user/local/server/gopath:/Users/peng/workspace/golang
export PATH=$PATH:$GOROOT/bin

如何写文章?

文章采用Markdown的写法,需要先了解Markdown的写法,基本用法与文档示例写法可查看Markdown基本用法。除此之外有几点需要注意:

1、文章放在posts目录中,文件夹可多层嵌套(无影响),文件需以md为后缀,文件名即文章标题。

2、md文件头部需写入文章头部,文章头部和文章正文以换行区分,示例如下:

{
    "url": "markdown",
    "time": "2016/11/01 19:45",
    "tag": "Markdown"
}

文章正文

文章头部采用json来描述文章信息,字段定义如下:

字段 必选 说明
url 文章URL
time 文章发表时间
tag 标签,多个标签用英文逗号分隔
public 为no的时候表示文章不可被浏览器访问到
toc 默认不渲染,为yes时渲染左侧目录

安装

go get github.com/pengbotao/itopic.go

启动

go run main.go

说明:

  -debug
    	debug mode
  -duration int
    	create html duration (default 300)
  -host string
    	host (default "127.0.0.1:8001")
  -html
    	is create html
  -prefix string
    	html folder (default "../itopic.org")
  • -debug: 文档修改后访问浏览器实时看到效果,同时public为no的文章也会显示
  • -html: 往prefix目录写生成的html数据,默认每5分钟写一次

发布

这里以为发布到github pages上为例。由于只支持静态页面,所以可以通过go的程序指定下生成静态页面的目录,然后将静态页面提交到github上来。参考https://github.com/pengbotao/pengbotao.github.io

  1. 创建username.github.io,将生成的静态页面提交到master分支。
  2. 访问username.github.io/index.html是否正常。
  3. 访问username.github.io,若出现404,
    • 需要添加README文件
    • 在仓库的Settings -> Change Theme 选择一个主题然后保存,此时会在项目中生成一个_config.yml文件,重新访问即可。

itopic.go's People

Contributors

pengbotao avatar cyrilbois avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.