Best way to use my own server to host my jekyll site?

I have tried GitHub pages to host my site, but I have found some problems and concerns with it that made me think it was better to use my own server.

Now I have a server with nginx that servers other sites and content.

I am looking for the best strategy, and thinking of two posible strategies.
I would like opinions on which is best and how to implement it.

1. Install Jekyll and GIT.

This approach would be the GitHub way but with your own server.
Install Jekyll in it and let it generate the online site from the sources each time a document is changed.

In order to update the documents and have complete versioning you need a git server in your online server.
Installing a Jekyll and a git servers does not seem complicate.

But I need guidance with some aspects:

  1. Once installed Jekyll, how do I keep it running in order to recreate the site each time a source does change?
    I suppose it is as easy as creating a “nohup Jekyll -build” to initd or something like that.
    Should I redirect the output to a log file or it may get too big, and better sending it to /dev/null?
    How to launch Jekyll again automatically if it crashes?

  2. Once installed a git server, How do I create and upload the local git repository using atom?
    How do I connect atom with the repository using a secure connection?

  3. To publish the site online, I will direct nginx to the generated _site directory, I suppose it is the correct way of doing it, and it would detect and serve any change in generated files.
    Any problems with caching or something like that?

2. Just upload the generated _site using a syncing tool

Another aproach, probably easier to use, would be to use a one way sync tool like rsync to upload to the server just the generated _site files, and serve them using nginx as a static file server.

The git version control would be used locally only.
The problem I see is that I loose the pull step, and any commit when I am testing changes would be uploaded to the server, but it would be simple to maintain.
And I would need another tool like rsync for the sync.

1 Like

I Think Is The Best.

Thank you but i am thinking of a self hosted system.

I am using Jekyll to simpliify things and depend on as few external services as i can.

I don’t want stripped down free services that charge money when your needs increase.

not sure I can help with the entire workflow, but for #1:

  1. you could run a script to run jekyll build
  2. you could do a git pull to pull down the latest, again in a script
  3. the _site folder would update when jekyll builds, should be fine.

I think you could have a git hook on the server that would see when you push and then would trigger the script that would pull the changes locally and run jekyll build. I have one project where I do this except the git hook part - I just ssh in and run a bash script that pulls the repo and builds the site.

That said I find hosting on S3 to be easier, practically free. But it can be complicated.

I am working on using GitLab CI/runners to push my site to S3 and invalidate files on cloud front. It is a little complicated and does rely on several/numerous pieces to all work together. But you get free ssl, a CDN and some other stuff that to me makes it worth it.