Bài viết được sự cho phép của tác giả Nguyễn Việt Hưng
I. Markdown
Markdown được nói trong bài này là cú pháp để phục vụ việc chuyển text thành HTML. Tức là khi viết bằng cú pháp markdown, đưa qua 1 chương trình xử lý, nó sẽ cho ra kết quả là HTML.
Kết quả: (lưu ý, xem source html của kết quả để biết chính xác, việc trình bày có thể bị ảnh hưởng bới template của blog)
H1
H2
H3
H4
H5
H6
Định dạng chữ:
Chữ nghiêng:*nghiêng* hoặc _nghiêng_.(*: asterik, _: underscore)Chữđậm:**đậm** hoặc __đậm__.Nghiêng đậm:**_nghiêng đậm_** hoặc *__nghiêng đậm__*
Gạch ngang chữ:<s>gạch ngang</s>
Kết quả:
Chữ nghiêng: nghiêng hoặc nghiêng. (*: asterik, _: underscore)
Chữ đậm: đậm hoặc đậm.
Nghiêng đậm: nghiêng đậm hoặc nghiêng đậm
Gạch ngang chữ: gạch ngang
Link
[I'm an inline-style link](http://fml.vn)
[I'm an inline-style link with title](http://fml.vn "FML Academy")[I'm a reference-style link][Arbitrary case-insensitive reference text]
[I'm a relative reference to a repository file](../blob/master/LICENSE)[You can use numbers for reference-style link definitions][1]Or leave it empty anduse the [link text itself].[arbitrary case-insensitive reference text]: http://fml.vn[1]: http://fml.vn[link text itself]:http://fml.vn
You can use numbers for reference-style link definitions
Or leave it empty and use the link text itself.
Image
Here's our logo (hover to see the title text):
Inline-style:

Reference-style:
![alt text][logo]
[logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"
2. Tạo thư mục chứa blog và chạy pelican-quickstart để thiết lập các thông số ban đầu:
(venv)╭─htl@htl-homeserver ~/pelican
╰─$ mkdir blog
mkdir: created directory 'blog'(venv)╭─htl@htl-homeserver ~/pelican
╰─$ cd blog
(venv)╭─htl@htl-homeserver ~/pelican/blog
╰─$ pelican-quickstart
Welcome to pelican-quickstart v3.6.3.This script will help you create a newPelican-based website.Please answer the following questions so this script can generate the files
needed byPelican.>Wheredo you want to create your new web site?[.]>What will be the title ofthis web site?Test blog
>Who will be the author ofthis web site? htl
>What will be the default language ofthis web site?[en] vn
>Do you want to specify a URL prefix? e.g., http://example.com (Y/n) n>Do you want to enable article pagination?(Y/n) y
>How many articles per page do you want?[10]>Whatis your time zone?[Europe/Paris]Asia/Ho_Chi_Minh>Do you want to generate a Fabfile/Makefile to automate generation and publishing?(Y/n) y
>Do you want an auto-reload & simpleHTTP script to assist with theme and site development?(Y/n) y
>Do you want to upload your website using FTP?(y/N) n
>Do you want to upload your website using SSH?(y/N) n
>Do you want to upload your website usingDropbox?(y/N) n
>Do you want to upload your website using S3?(y/N) n
>Do you want to upload your website usingRackspaceCloudFiles?(y/N) n
>Do you want to upload your website usingGitHubPages?(y/N) y
>Isthis your personal page (username.github.io)?(y/N) n
Done.Yournew project is available at /home/htl/pelican/blog
Đơn giản là chỉ cần tạo 1 file .md tại thư mục /blog/content, nội dung file được định dạng theo cú pháp markdown.
Các thông tin (metadata) cần thiết cho 1 bài viết được ghi ngay trên đầu file. Metadata tối thiểu bắt buộc phải có là Title, ngoài ra với cấu hình mặc định thì nên thêm Date:
Nếu metadata Date không được cung cấp trong nội dung bài viết thì pelican sẽ lấy thời gian tạo ra file, với điều kiện trong file pelicanconf.py phải có dòng (mà mặc định là chưa có):
DEFAULT_DATE='fs'
4. Tạo file html:
Điều kiện là khi khởi tạo bằng lệnh pelican-quickstart phải bật công cụ tự động tạo html ở câu hỏi này:
>Do you want to generate a Fabfile/Makefile to automate generation and publishing?(Y/n) y
Khi đó sẽ có file Makefile tại thư mục gốc của blog. Tạo blog bằng cách chạy lệnh make html:
(venv)╭─htl@htl-homeserver ~/pelican/blog
╰─$ make html
pelican /home/htl/pelican/blog/content -o /home/htl/pelican/blog/output -s /home/htl/pelican/blog/pelicanconf.py
Done:Processed1 article,0 drafts,0 pages and0 hidden pages in0.22 seconds.
Vậy là đã tạo được 1 file html trong thư mục output (ngang hàng với content).
Thử xem blog mình vừa viết trông như thế nào, dùng lệnh make serve:
(venv)╭─htl@htl-homeserver ~/pelican/blog
╰─$ make serve
cd /home/htl/pelican/blog/output && python -m pelican.server
1. Tạo 1 github repo có tên là username.github.io với username là tên tài khoản github của bạn.
2. Clone repo về local:
(venv)╭─htl@htl-homeserver ~/pelican
╰─$ git clone git@github.com:fmltestblog/fmltestblog.github.io.git
Cloninginto'fmltestblog.github.io'...
warning:You appear to have cloned an empty repository.
3. Copy tất cả folder output vào thư mục của github repo: