---
title: "How to Publish a Jekyll Site with Git"
description: "In this article, we're going to show one way (among many) to automate the publishing process for a Jekyll site. This is an advanced article and requires referencing of other information. Where..."
url: https://www.inmotionhosting.com/support/website/jekyll/how-to-publish-a-jekyll-site-with-git/
date: 2018-03-08
modified: 2021-08-16
author: "Christopher Maiorana"
categories: ["Jekyll"]
type: post
lang: en
---

# How to Publish a Jekyll Site with Git

```
In this article, we're going to show one way (among many) to automate the publishing process for a Jekyll site.     This is an advanced article and requires referencing of other information.  Where appropriate, links to supporting material have been provided.      Before proceeding with this article, it is highly recommended that you familiarize yourself with Git.   Git is a popular version control system we will use to publish our site. 

    But, if you already know Git well, and you're ready to proceed, we will learn **how to publish a Jekyll site with Git**. 

  

## Make Sure Git is Installed

      In order to use the automation process we're going to show here, you must have Git installed on your computer (local) and your server (remote). 

  

## Initialize Git in Your Jekyll Directory

    First, we will need to go into our Jekyll site directory via command line and initiate a Git repository. 

 

VIGIAPLACEHOLDER0END

      You have now initialized a Git repository in your local site.   You can now use Git to version control your site and push it to your server.    Keep reading to find out how to accomplish this. 

  

## Add a Remote Repository to Your Server

   In this stage of the process, we're going to create a remote Git repository on our server.  This remote repository will server many purposes.   It will be a place to store your site information remotely, and thus can be used as backup.     It will also be able to "check out" or publish the site files. 

      Here we will reference our full guide on publishing files to your server with Git.   However, in this instance, use this as the post-receive hook:  
 #!/bin/sh git --work-tree=/home/userna5 --git-dir=/home/userna5/production.git checkout HEAD -- /public_html 

   As in the reference guide, make sure to substitute *userna5* with your correct cPanel username. 

  

## Change Your Site's Base Directory (Important)

      You may remember in the article about customizing Jekyll, we learned that you can change the "build" directory for your site.  This is know as the base directory.     It's the directory from which the site is served. 

   Your InMotion Hosting server (with cPanel) has already chosen `public_html` as the root directory for serving your site.  You could change this behavior, but it would be easier to work with it instead.     In order to do this you will just need to create a folder called `public_html` in your site directory.    Then, change the base directory for your site to that `public_html` folder.   Now, when you run the jekyll build command, your site files will be built in the `public_html` directory. 

  

## Completing the Process

   Now you have a local and remote repository for your site.   Using the jekyll build command, you can now build your site to the `public_html` directory.  Then, you can use Git to push the site to the remote repository and simultaneoulsy checkout the site files to the appropriate folder.
```
