blog


Jul. 23, 2020

Hugo Theme Twentytwenty

Blog theme is the one of my writing motivation. Once I saw some nice looking themes, I would like to use it on my blog, or reinvent the wheel.

Apr. 24, 2020

Move Hexo to Hugo

What is Hugo? Hugo is a static site generator written in Go. It is optimized for speed, easy use and configurability. Hugo takes a directory with content and templates and renders them into a full html website. Hugo makes use of markdown files with front matter for meta data. Hexo vs Hugo Hexo is also fast and simple, it is a static blog generator, and Hugo is more like for a site not only blog. Hexo is written in Node.js. Since I am a Golang developer now. I think it is good to move to Hugo. Prepare Hugo Check the Hugo official page Migrate to Hugo before you do it by yourself. Hugo has different content structure than Hexo. First of all, remove any unrelated files like themes, submodules, hexo config file… for removing submodules from https://stackoverflow.com/questions/1260748/how-do-i-remove-a-submodule/36593218#36593218 # Remove the submodule entry from .git/config git submodule deinit -f path/to/submodule # Remove the submodule directory from the superproject's .git/modules directory rm -rf .git/modules/path/to/submodule # Remove the entry in .gitmodules and remove the submodule directory located at path/to/submodule git rm -f path/to/submodule Then, Install Hugo and run hugo new site --force in the current folder, it will generate the mandatory files for the site. Add theme you like and do configuration. Move all posts to the new content folder, I put mine into the content/posts. Update the front matter of the posts to avoid compile error in the Hugo. That’s almost done, it is easy because I moved my site from Jekyll to Hexo, then to Hugo, they all use markdown files and front matter for the post.

Sep. 24, 2014

Install Ghost with Nginx and MySQL

The steps I installed Ghost blog on Linode with Debian 7.5 Prepare apt-get update apt-get upgrade apt-get install -y build-essential Installing Nginx apt-get install nginx Install Node.js Based on here Setup with Debian (as root): curl -sL https://deb.nodesource.com/setup | sudo bash - Then install with Debian (as root): apt-get install -y nodejs nodejs-legacy Install MySQL apt-get install mysql-client mysql-server Secure MySQL mysql_secure_installation Restart MySQL /etc/init.d/mysql restart or service mysql restart Using MySQL mysql -u root -p to setup database: CREATE DATABASE YOUR_DATABASE; CREATE USER 'YOUR_USERNAME' IDENTIFIED BY 'YOUR_PASSWORD'; GRANT ALL PRIVILEGES ON YOUR_DATABASE.* TO 'YOUR_USERNAME'; exit Install Ghost Based on here created /var/www/ghost as ghost folder mkdir -p /var/www/ cd /var/www/ curl -L https://ghost.org/zip/ghost-latest.zip -o ghost.zip unzip -uo ghost.zip -d ghost cd /var/www/ghost Then setup ghost environment npm install --production npm install mysql npm install forever -g Setup Ghost Copy over the example config file and then edit it cp config.example.js config.js vim /var/www/ghost/config.js Change production default url to your domain and setup MySQL database url: 'http://YOUR_DOMAIN', database: { client: 'mysql', connection: { host: 'localhost', user: 'YOUR_USERNAME', password: 'YOUR_PASSWORD', database: 'YOUR_DATABASE', charset: 'utf8' } }, Run Ghost as background process Fix all permission chown -R www-data:www-data /var/www/ghost Then run ghost as background process by forever (you can find other deply methods in here) NODE_ENV=production forever start index.js Setup Nginx vim /etc/nginx/sites-available/ghost server { listen 80; server_name example.com www.example.com; location / { proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.