1
votes

I have created jekyll site. Regarding the deployment I don't want to host on github pages. To host private domain I came know from documentation to copy the all files from _site folder. That's all wicked.

Question:

  1. Each time I add new blog post, I am running cmd>jekyll build then I am copying newly created html to hosted domain. Is there any easy way to update without compiling each time ?

  2. The reason, Why I am asking is because it will updated by non technical person

Thanks for the help!!

2

2 Answers

2
votes

If you don't want to use GitHub Pages, AFAIK there's no other way than to compile your site each time you make a change.

But of course you can script/automate as much as possible.
That's what I do with my own blog as well. I'm hosting it on my own webspace instead of GitHub Pages, so I need to do these steps for each update:

  1. Compile on local machine
  2. Upload via FTP

I can do this with a single click (okay, a single double-click).


Note: I'm on Windows, so the following solution is for Windows.
But if you're using Linux/MacOS/whatever, of course you can use the tools given there to build something similar.


I'm using a batch file (the Windows equivalent to a shell script) to compile my site and then call WinSCP, a free command-line FTP client.

WinSCP allows me to store session configurations, so I saved the connection to my server there once.
Because of this, I didn't want to commit WinSCP to my (public) repository, so my script expects WinSCP in the parent folder.

The batch file looks like this:

call jekyll build

echo If the build succeeded, press RETURN to upload!

pause

set uploadpath=%~dp0\_site
%~dp0\..\winscp.com /script=build-upload.txt /xmllog=build-upload.log

pause

The first parameter in the WinSCP call (/script=build-upload.txt) specifies the script file which contains the actual WinSCP commands

This is in the script file:

option batch abort
option confirm off

open blog
synchronize remote -delete "%uploadpath%"

close
exit

Some explanations:

  1. %~dp0 (in the batch file) is the folder where the current batch file is
  2. The set uploadpath=... line (in the batch file) saves the complete path to the generated site into an environment variable
  3. The open blog line (in the script file) opens a connection to the pre-saved session configuration (which I named blog)
  4. The synchronize remote ... line (in the script file) uses the synchronize command to sync from the local folder (saved in %uploadpath%, the environment variable from step 2) to the server.

IMO this solution is suitable for non-technical persons as well.
If the technical person in your case doesn't know how to use source control, you could even script committing & pushing, too.

2
votes

There are a number of options available which are mentioned in the documentation: http://jekyllrb.com/docs/deployment-methods/

If you are using Git, I would recommend the Git Post-Receive Hook approach. It simply builds the site after the new code is received:

GIT_REPO=$HOME/myrepo.git
TMP_GIT_CLONE=$HOME/tmp/myrepo
PUBLIC_WWW=/var/www/myrepo

git clone $GIT_REPO $TMP_GIT_CLONE
jekyll build -s $TMP_GIT_CLONE -d $PUBLIC_WWW
rm -Rf $TMP_GIT_CLONE
exit

Since you mentioned that it will be updated by a non-technical person, you might try something like rack-jekyll to automatically rebuild when new files are FTP'd.