Total Pageviews

Thursday, 12 January 2017

搭建基于haskell的静态博客程序alfredodinapoli.com

首先按此文http://briteming.blogspot.com/2016/07/haskellghc.html安装ghc,cabal和hakyll。
(如果你之前用命令stack install hakyll安装过hakyll,这里就无须再用命令cabal install hakyll来安装hakyll了)

cd /usr/local
git clone https://github.com/adinapoli/alfredodinapoli.com
cd alfredodinapoli.com

root@localhost:/usr/local/alfredodinapoli.com# ls
css    drafts   posts        website.cabal
code          cv     img      README    SiteCtl.hs  stack.yaml
content       cv_eu  js       Setup.hs  static
create_draft  doc    LICENSE  site.hs     templates
root@localhost:/usr/local/alfredodinapoli.com#  ghc --make site.hs
(此步会遇错:
[1 of 1] Compiling Main ( site.hs, site.o ) site.hs:5:1: error:
Failed to load interface for ‘Shelly’
Use -v to see a list of the files searched for.

解决办法:cabal install shelly)
root@localhost:/usr/local/alfredodinapoli.com#  ghc --make site.hs
(这次不会遇错了)
root@localhost:/usr/local/alfredodinapoli.com# ls
css    drafts   posts     site.o      website.cabal
code          cv     img      README    SiteCtl.hs  stack.yaml
content       cv_eu  js       Setup.hs  site.hi     static
create_draft  doc    LICENSE  site      site.hs     templates
(成功生成了可执行文件site)
root@localhost:/usr/local/alfredodinapoli.com#  ./site build
root@localhost:/usr/local/alfredodinapoli.com# ls
_cache        css    drafts   posts     _site       site.o      website.cabal
code          cv     img      README    SiteCtl.hs  stack.yaml
content       cv_eu  js       Setup.hs  site.hi     static
create_draft  doc    LICENSE  site      site.hs     templates
root@localhost:/usr/local/alfredodinapoli.com#  cd _site
root@localhost:/usr/local/alfredodinapoli.com/_site# ls
contacts.html  cv_eu    doc  index.html  oss.html  posts.html  tags
css            cv.html  img  js          posts     rss.xml     talks.html
root@localhost:/usr/local/alfredodinapoli.com/_site#
(可见/usr/local/alfredodinapoli.com/_site就是静态网站的根目录)

新建源帖:
root@localhost:/usr/local/alfredodinapoli.com/_site# cd ../posts
root@localhost:/usr/local/alfredodinapoli.com/posts# nano 2017-01-12-test-1.markdown
root@localhost:/usr/local/alfredodinapoli.com/posts# cat 2017-01-12-test-1.markdown
---
title: 测试1
tags: misc1, misc2, misc3
---

这是测试1.

看看如何?

root@localhost:/usr/local/alfredodinapoli.com/posts#  cd ..
root@localhost:/usr/local/alfredodinapoli.com# ./site build

演示网站:http://adn.bright.biz.st/,http://adn.bright.biz.st/posts.html
项目地址:https://github.com/adinapoli/alfredodinapoli.com/,
https://github.com/adinapoli/alfredodinapoli.com/issues/2

No comments:

Post a Comment