Migol's Blog

Programming, technology, productivity, Blender and gaming.

Hexo and Rsync on Windows May 22, 2015

I guess first post should be about how exactly did I make Hexo work with rsync. Actually, after searching for ready to use solution in Google I tried few things and of course they didn’t work. Reason for that is that rsync doesn’t really like Windows – it’s a typical Unix/Linux tool. You can of course make it work without Hexo command, but what I really wanted is to make it work like it was intended to work. Here’s what I did.

First of all, you need to get Cygwin. For those who don’t know it, Cygwin is a Linux “emulator” running on Windows (please, don’t quote me on that, I know it’s wrong). While installing, remember to select 2 packages: rsync and openssh. After it’s done, you need to start bash shell that it gives. Now commands time.

$ ssh-keygen

This will generate SSH key that Cygwin will use to communicate with SSH server on the other side (I use rsync over SSH as oposed to rsync daemon, but it’s probably same). After giving your key a passphrase (or not) we need to upload it to server. Best case scenario: you can login using password. If so, you can simply issue:

$ ssh-copy-id user@host [-p port]

This way remote server will know who you are. If you can’t, read your public key using:

$ cat ~/.ssh/id_rsa.pub

Then paste it to your ~/.ssh/authorized_keys file on remote machine and you should be good to go.

Now the fun part, configuring Hexo. This is quite simple snippet:

  type: rsync
  host: <hostname>
  port: <port>
  user: <login>
  root: <absolute path to folder for your blog>

No magic here. Now from Cygwin shell, you can execute:

$ hexo generate
$ hexo deploy

And… It might not work because rsync or rather OpenSSH that is under it, doesn’t like easy access to your private key. There is an easy fix to it. First you need to change group for key file (we execute these in Cygwin):

$ chgrp Users ~/.ssh/id_rsa

This might be tricky as Users is only valid in English Windows. If you have different language, you need to adjust it, for example, in Polish, that command would be:

$ chgrp U┼╝ytkownicy ~/.ssh/id_rsa

Next thing is to change permissions themselves. This should do the trick:

$ chmod 600 ~/.ssh/id_rsa

After all of that work, you can now execute hexo deploy again and be a happy owner of easy to deploy Hexo blog.

One thing that I couldn’t make to work is permissions on remote side. Whenever I push my changes, I have to execute:

$ ssh user@host chmod -R a+rx DIR_WITH_BLOG

I still have no idea how to fix it, but it’s good enough workaround for now.

No Comments on Hexo and Rsync on Windows
Categories: Uncategorized

Hexo blog

This post have been moved from my old blog. Why it died? Limitations of what I could do with it and time I would have to spend to do it. WordPress when you don’t have time to work on details of blog is very nice. Oh, and a bug that was there with Hexo…

Since I got more and more interested in Node.js, I wanted platform that uses it. Thing is that my hosting service, LinuxPL, doesn’t support it. It’s cheap, has very good uptime and Ruby support, but for Node I would have to pay. However, I think I have solution for that.

Blogs are very simple beasts. Just a static HTML would do most of the time, but then you have to manage dates, front page, etc. This is all author-created content. Readers would also like to comment and this is really only reader-created content. There is a way to circumvent that.

Let’s start with comments. One of the most popular ways to have comments on your website is to use Disqus. It allows users to both have comments on their websites for free and manage them, and to have a single online profile for commenting and tracking. It’s used by some major blogs, at least in Poland, supports few Single Sign-On providers (G+, Facebook, Twitter…). Why not?

Now for the author-created content, I decided to go for Hexo. Light, fast, supports plugins and publishing is actually generating static HTML files. On top of that thanks to plugins, I have a huge choice of what I want to use as markup language. I decided that, for now at least, I will stay with default of Markdown syntax. Did I mention that it also supports multiple languages for code highlighting? Whole thing has a very simple installation process via NPM package and you are ready to go. Here’s a short snippet:

$ npm install hexo -g
$ hexo init blog
$ cd blog
$ npm install

and you are ready to mess with config, create new posts and deploy it. Simple.

To transfer my blog to my server, I had to choose rsync. It might not be best or fastest, but it gets the job done. Also, I have a private BitBucket Git repository and as editor of choice I went for Atom, written in… NodeJS! I’ll try to talk more about that particular editor in future posts as it seems to be really great tool to use.

That’s it. Disqus, Node, Markdown, Rsync, Git and Atom combined to provide me with a great, streamlined blogging platform.

No Comments on Hexo blog
Categories: Uncategorized