After starting my web presence almost a year ago with Grav, I haven't really given it too much love... I stopped by today, wanting to do some work on blogposts -- realizing that I have a good chance of implementing a really good workflow here...

Gitlab Community Edition Server

I do run a personal Gitlab Community Edition server for different reasons, the main one being that I at one point found it fascinating to learn how to run such a thing -- and remained using it. It might be a bit of an overkill for what I really need, but since I keep having it updated regularely, using it for my private projects, I thought I could use it for blogpost publishing reasons as well.

The Workflow

In rough terms, my new workflow looks something like this:

  1. Create a new blogpost locally

  2. Use the headers

    title: 'My shiny title'
    published: false

    in the Markdown file to provide a title and an unpublished state (enabling me to first finish the draft before it goes live)

  3. Make a git commit and git push to the remote

  4. Pull the content from my webhosting

  5. Finish up the blogpost (either from my Mac, my iPad or even from my iPhone, using Working Copy on the latter two)

  6. Publish the blogpost by either setting the header to published: true or activating the post via Grav`s admin plugin

The Preparations

In order for the above workflow to work, a few preparing steps were neccessary.

On my Gitlab server, I created a new project. Then, I sshed into my webhosting. I went down to the site content folder, which in my case is ~/public_html/ Right now, I only have 2 pages (represented by 2 folders) there, one being the starting page of the blog itself. So in there, I started a git repository with git init. By issuing the commands git add . and git commit -m "Inital message in the webhost's ssh session, I created my first git commit with the already available content.

To actually be able to push that stuff from my webhosting to my new Gitlab project, I set the git remote with git remote add origin git@name-of-server.tld:username/project-name.git (please fill in you own path here!). I then created a new private- / public-key pair to get access to my Gitlab server from my webhosting — there's a good set of instructions here — and made the public key available in Gitlab.

With all that in place, I could git push -u origin master everything to my Gitlab server. With that in place, with a git clone git@name-of-server.tld:username/project-name.git run locally on my Mac, I was able to create a local copy of my repository.

I also did add this new repository to my iPad's and iPhone's Working Copy, so that I have access to my blogposts now from all of my devices. I you should have never heard of Working Copy, you are really missing out — it is one of the best productivity apps that are out there! If you have anything to do with git, you gonna need this app (no, I don't have an affiliation with them whatsoever, I just think it's an awesome application).

What's next

Right now, I have to do commits locally, push them to Gitlab and then ssh into my webhosting, pulling the content there. It would be nice if the last step could be automated. I am considering to have a cronjob for a bash script there to try to pull every few minutes — I guess the CPU and traffic load will be minimal so I even might be checking every other minute or so.

This would mean that I don't have to ssh into yet another machine; I could do it all locally.

Comments on this?

If you should have any questions, suggestions or other input on this, please don't hesitate to contact me via Twitter where I am @appfrosch.

Previous Post