Finish up last of hosting-and-deployment transfer from old site
@ -9,18 +9,19 @@ categories: [contribute to hugo]
|
||||
tags: [dev,open source]
|
||||
weight: 10
|
||||
draft: false
|
||||
aliases: []
|
||||
aliases: [/contribute-to-hugo/contribute-to-hugo-development/]
|
||||
toc: true
|
||||
needsreview: true
|
||||
notesforauthors:
|
||||
---
|
||||
|
||||
## Introduction
|
||||
|
||||
Hugo is an open source project and lives by the work of its [contributors](https://github.com/spf13/hugo/graphs/contributors). Help to make Hugo even more awesome. There are plenty of [open issues](https://github.com/spf13/hugo/issues) on GitHub and we need your help.
|
||||
Hugo is an open-source project and lives by the work of its [contributors](https://github.com/spf13/hugo/graphs/contributors). Help to make Hugo even more awesome. There are plenty of [open issues](https://github.com/spf13/hugo/issues) on GitHub, and we need your help.
|
||||
|
||||
This tutorial is intended for people who are new to Git, GitHub or open source projects in general. It should help to overcome most of the barriers that newcomers encounter. It describes step by step what you need to do.
|
||||
|
||||
For any kind of questions please take a look at our [forum](https://discuss.gohugo.io/).
|
||||
For any kind of questions please take a look at the [Hugo Discussion forum](https://discuss.gohugo.io/).
|
||||
|
||||
## Install Go
|
||||
|
||||
@ -110,11 +111,11 @@ If you're not fimiliar with this term, GitHub's [help pages](https://help.github
|
||||
|
||||
Open the [Hugo repository](https://github.com/spf13/hugo) on Github and click on the "Fork" button in the top right.
|
||||
|
||||

|
||||

|
||||
|
||||
Now open your fork repository on GitHub and copy the remote url of your fork. You can choose between HTTPS and SSH as protocol that Git should use for the following operations. HTTPS works always [if you're not sure](https://help.github.com/articles/which-remote-url-should-i-use/).
|
||||
|
||||

|
||||

|
||||
|
||||
Switch back to the terminal and move into the directory of the cloned master repository from the last step.
|
||||
|
||||
@ -320,7 +321,7 @@ We made a lot of progress. Good work. In this step we finally open a pull reques
|
||||
|
||||
You should find a green button labeld with "New pull request". But GitHub is clever and probably suggests you a pull request like in the beige box below:
|
||||
|
||||

|
||||

|
||||
|
||||
The new page summaries the most important information of your pull request. Scroll down and you find the additions of all your commits. Make sure everything looks as expected and click on "Create pull request".
|
||||
|
||||
@ -328,13 +329,13 @@ The new page summaries the most important information of your pull request. Scro
|
||||
|
||||
Last but not least you should accept the contributor license agreement (CLA). A new comment should be added automatically to your pull request. Click on the yellow badge, accept the agreement and authenticate yourself with your GitHub account. It just takes a few clicks and only needs to be done once.
|
||||
|
||||

|
||||

|
||||
|
||||
### Automatic builds
|
||||
|
||||
We use the [Travis CI loop](https://travis-ci.org/spf13/hugo) (Linux and OS X) and [AppVeyor](https://ci.appveyor.com/project/spf13/hugo/branch/master) (Windows) to compile Hugo with your additions. This should ensure that everything works as expected before merging your pull request. This in most cases only relevant if you made changes to the codebase of Hugo.
|
||||
|
||||

|
||||

|
||||
|
||||
Above you can see that Travis wasn't able to compile the changes in this pull request. Click on "Details" and try to investigate why the build failed. But it doesn't have to be your fault. Mostly, the `master` branch that we used as foundation for your pull request should build without problems.
|
||||
|
||||
|
@ -12,7 +12,6 @@ weight: 10
|
||||
draft: false
|
||||
aliases: [/overview/quickstart/]
|
||||
toc: true
|
||||
needsreview: true
|
||||
notesforauthors:
|
||||
---
|
||||
|
||||
@ -542,6 +541,8 @@ After you run the `hugo` command, a `bookshelf/public` directory will be created
|
||||
|
||||
{{% note "GitHub Account" %}}
|
||||
The following step assumes that you have a working familiarity with Git version control and also a GitHub account. A GitHub account is required to leverage Pages, a static website hosting service that is complimentary for GitHub users. [Setting up a GitHub account is free](https://github.com/join).
|
||||
|
||||
There is more than one way to host your site on GitHub. Be sure to check out [Hosting on GitHub](/hosting-and-deployment/hosting-on-github/) and [Deployment with Wercker](/hosting-and-deployment/deployment-with-wercker).
|
||||
{{% /note %}}
|
||||
|
||||
First, let's set up Git version control for your bookshelf website and include a `.gitignore` file to prevent tracking of the `public` and `themes` directories. From within your root project directory, you can use the following one-liner:
|
||||
|
@ -13,6 +13,7 @@ slug:
|
||||
aliases: [/getting-started/using-the-docs/]
|
||||
toc: true
|
||||
notesforauthors:
|
||||
needsreview: true
|
||||
---
|
||||
|
||||
## Example Site
|
||||
|
@ -7,9 +7,129 @@ publishdate: 2017-02-01
|
||||
lastmod: 2017-02-01
|
||||
categories: [hosting and deployment]
|
||||
tags: [rysnc,deployment]
|
||||
toc: false
|
||||
authors: [Adrien Poupin]
|
||||
weight:
|
||||
draft: false
|
||||
aliases: []
|
||||
aliases: [/tutorials/deployment-with-rsync/]
|
||||
toc: true
|
||||
needsreview: true
|
||||
notesforauthors:
|
||||
---
|
||||
---
|
||||
|
||||
## Assumptions
|
||||
|
||||
* Access to your web host with SSH
|
||||
* A functional static website built with Hugo
|
||||
|
||||
The spoiler is that you can deploy your entire website with a command that looks like the following:
|
||||
|
||||
```bash
|
||||
hugo && rsync -avz --delete public/ www-data@ftp.topologix.fr:~/www/
|
||||
```
|
||||
|
||||
As you will see, we put it in a shell script file, which makes building and deployment as easy as executing `./deploy`.
|
||||
|
||||
## Installing SSH Key
|
||||
|
||||
If it is not done yet, we will make an automated way to SSH to your server. If you have already installed an SSH key, switch to the next section.
|
||||
|
||||
First, install the ssh client. On Debian/Ubuntu/derivates, use the following command:
|
||||
|
||||
{{% input "install-openssh.sh" %}}
|
||||
```bash
|
||||
sudo apt-get install openssh-client
|
||||
```
|
||||
{{% /input %}}
|
||||
|
||||
Then generate your ssh key by entering the following commands:
|
||||
|
||||
```bash
|
||||
~$ cd && mkdir .ssh & cd .ssh
|
||||
~/.ssh/$ ssh-keygen -t rsa -q -C "For SSH" -f rsa_id
|
||||
~/.ssh/$ cat >> config <<EOF
|
||||
Host HOST
|
||||
Hostname HOST
|
||||
Port 22
|
||||
User USER
|
||||
IdentityFile ~/.ssh/rsa_id
|
||||
EOF
|
||||
```
|
||||
|
||||
Don't forget to replace the `HOST` and `USER` values with your own ones. Then copy your ssh public key to the remote server:
|
||||
|
||||
```bash
|
||||
~/.ssh/$ ssh-copy-id -i rsa_id.pub USER@HOST.com
|
||||
```
|
||||
|
||||
Now you can easily connect to the remote server:
|
||||
|
||||
```
|
||||
~$ ssh user@host
|
||||
Enter passphrase for key '/home/mylogin/.ssh/rsa_id':
|
||||
```
|
||||
|
||||
And you've done it!
|
||||
|
||||
## Shell Script
|
||||
|
||||
We will put the first command in a script at the root of your Hugo tree:
|
||||
|
||||
```bash
|
||||
~/websites/topologix.fr$ editor deploy
|
||||
```
|
||||
|
||||
Here you put the following content. Replace the `USER`, `HOST`, and `DIR` values with your own:
|
||||
|
||||
```bash
|
||||
#!/bin/sh
|
||||
USER=my-user
|
||||
HOST=my-server.com
|
||||
DIR=my/directory/to/topologix.fr/ # might sometimes be empty!
|
||||
|
||||
hugo && rsync -avz --delete public/ ${USER}@${HOST}:~/${DIR}
|
||||
|
||||
exit 0
|
||||
```
|
||||
|
||||
Note that `DIR` is the relative path from the remote user's home. If you have to specify a full path (for instance `/var/www/mysite/`) you must change `~/${DIR}` to `${DIR}` inside the command line. For most cases you should not have to.
|
||||
|
||||
Save and close, and make the `deploy` file executable:
|
||||
|
||||
```
|
||||
~/websites/topologix.fr$ chmod +x deploy
|
||||
```
|
||||
|
||||
Now you only have to enter the following command to deploy and update your website:
|
||||
|
||||
```
|
||||
~/websites/topologix.fr$ ./deploy
|
||||
Started building sites ...
|
||||
Built site for language en:
|
||||
0 draft content
|
||||
0 future content
|
||||
0 expired content
|
||||
5 pages created
|
||||
0 non-page files copied
|
||||
0 paginator pages created
|
||||
0 tags created
|
||||
0 categories created
|
||||
total in 56 ms
|
||||
sending incremental file list
|
||||
404.html
|
||||
index.html
|
||||
index.xml
|
||||
sitemap.xml
|
||||
cours-versailles/index.html
|
||||
exercices/index.html
|
||||
exercices/index.xml
|
||||
exercices/barycentre-et-carres-des-distances/index.html
|
||||
post/
|
||||
post/index.html
|
||||
sujets/index.html
|
||||
sujets/index.xml
|
||||
sujets/2016-09_supelec-jp/index.html
|
||||
tarifs-contact/index.html
|
||||
|
||||
sent 9,550 bytes received 1,708 bytes 7,505.33 bytes/sec
|
||||
total size is 966,557 speedup is 85.86
|
||||
```
|
@ -10,7 +10,7 @@ tags: [wercker,deployment,github,git]
|
||||
authors: [Arjen Schwarz, Samuel Debruyn]
|
||||
toc: false
|
||||
draft: false
|
||||
aliases: []
|
||||
aliases: [/tutorials/automated-deployments/]
|
||||
toc: true
|
||||
needsreview: false
|
||||
notesforauthors:
|
||||
|
@ -2,14 +2,141 @@
|
||||
title: Hosting on Bitbucket
|
||||
linktitle: Hosting on Bitbucket
|
||||
description:
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-02-01
|
||||
date: 2017-02-04
|
||||
publishdate: 2017-02-04
|
||||
lastmod: 2017-02-04
|
||||
categories: [hosting and deployment]
|
||||
tags: [hosting,bitbucket]
|
||||
tags: [hosting,bitbucket,deployment,aerobatic]
|
||||
authors: [Jason Gowans]
|
||||
weight:
|
||||
draft: false
|
||||
toc: false
|
||||
aliases: []
|
||||
toc: true
|
||||
aliases: [/tutorials/hosting-on-bitbucket/]
|
||||
needsreview: true
|
||||
notesforauthors:
|
||||
---
|
||||
---
|
||||
|
||||
## Introduction
|
||||
|
||||
You can use [Bitbucket](https://bitbucket.org/) and [Aerobatic](https://www.aerobatic.com) to build, deploy, and host a Hugo website. Aerobatic is a static hosting service that integrates with Bitbucket and provides a free hosting tier.
|
||||
|
||||
## Assumptions
|
||||
|
||||
* Working familiarity with Git for version control
|
||||
* A [Bitbucket account](https://bitbucket.org/account/signup/)
|
||||
|
||||
## Install Aerobatic CLI
|
||||
|
||||
If you haven't previously used Aerobatic, you'll first need to install the Command Line Interface (CLI) and create an account. For a list of all commands available, see the [Aerobatic CLI](https://www.aerobatic.com/docs/cli/) docs.
|
||||
|
||||
```bash
|
||||
npm install aerobatic-cli -g
|
||||
aero register
|
||||
```
|
||||
|
||||
## Create and Deploy Site
|
||||
|
||||
```bash
|
||||
hugo new site my-new-hugo-site
|
||||
cd my-new-hugo-site
|
||||
cd themes; git clone https://github.com/eliasson/liquorice
|
||||
hugo -t liquorice
|
||||
aero create # create the Aerobatic site
|
||||
hugo --baseURL https://my-new-hugo-site.aerobatic.io # build the site overriding baseURL
|
||||
aero deploy -d public # deploy output to Aerobatic
|
||||
|
||||
Version v1 deployment complete.
|
||||
View now at https://hugo-docs-test.aerobatic.io
|
||||
```
|
||||
|
||||
In the rendered page response, the `https://__baseurl__` will be replaced with your actual site url (in this example, `https://my-new-hugo-site.aerobatic.io`). You can always rename your Aerobatic website with the `aero rename` command.
|
||||
|
||||
## Push Hugo site to Bitbucket
|
||||
|
||||
We will now create a git repository and then push our code to Bitbucket. In Bitbucket, create a repository.
|
||||
|
||||
![][1]
|
||||
|
||||
[1]: /images/hosting-and-deployment/hosting-on-bitbucket/bitbucket-create-repo.png
|
||||
|
||||
|
||||
```bash
|
||||
# initialize new git repository
|
||||
git init
|
||||
|
||||
# set up our .gitignore file
|
||||
echo -e "/public \n/themes \naero-deploy.tar.gz" >> .gitignore
|
||||
|
||||
# commit and push code to master branch
|
||||
git add --all
|
||||
git commit -m "Initial commit"
|
||||
git remote add origin git@bitbucket.org:YourUsername/my-new-hugo-site.git
|
||||
git push -u origin master
|
||||
```
|
||||
|
||||
## Continuous Deployment With Bitbucket Pipelines
|
||||
|
||||
In the example above, we pushed the compiled assets in the `/public` folder to Aerobatic. In the following example, we use Bitbucket Pipelines to continuously create and deploy the compiled assets to Aerobatic.
|
||||
|
||||
### Step 1: Configure Bitbucket Pipelines
|
||||
|
||||
In your Hugo website's Bitbucket repo;
|
||||
|
||||
1. Click the Pipelines link in the left nav menu of your Bitbucket repository.
|
||||
2. Click the Enable Pipelines button.
|
||||
3. On the next screen, leave the default template and click Next.
|
||||
4. In the editor, paste in the yaml contents below and click Commit.
|
||||
|
||||
```bash
|
||||
image: beevelop/nodejs-python
|
||||
pipelines:
|
||||
branches:
|
||||
master:
|
||||
- step:
|
||||
script:
|
||||
- apt-get update -y && apt-get install wget
|
||||
- apt-get -y install git
|
||||
- wget https://github.com/spf13/hugo/releases/download/v0.18/hugo_0.18-64bit.deb
|
||||
- dpkg -i hugo*.deb
|
||||
- git clone https://github.com/eliasson/liquorice themes/liquorice
|
||||
- hugo --theme=liquorice --baseURL https://__baseurl__ --buildDrafts
|
||||
- npm install -g aerobatic-cli
|
||||
- aero deploy
|
||||
```
|
||||
|
||||
### Step 2: Create `AEROBATIC_API_KEY` environment variable.
|
||||
|
||||
This step only needs to be done once per account. From the command line;
|
||||
|
||||
```bash
|
||||
aero apikey
|
||||
```
|
||||
|
||||
1. Navigate to the Bitbucket account settings for the account that the website repo belongs to.
|
||||
2. Scroll down to the bottom of the left nav and click the Environment variables link in the PIPELINES section.
|
||||
3. Create a new environment variable called AEROBATIC_API_KEY with the value you got by running the `aero apikey` command. Be sure to click the Secured checkbox.
|
||||
|
||||
### Step 3: Edit and Commit Code
|
||||
|
||||
```bash
|
||||
hugo new post/good-to-great.md
|
||||
hugo server --buildDrafts -t liquorice #Check that all looks good
|
||||
|
||||
# commit and push code to master branch
|
||||
git add --all
|
||||
git commit -m "New blog post"
|
||||
git push -u origin master
|
||||
```
|
||||
|
||||
Your code will be committed to Bitbucket, Bitbucket Pipelines will run your build, and a new version of your site will be deployed to Aerobatic.
|
||||
|
||||
At this point, you can now create and edit blog posts directly in the Bitbucket UI.
|
||||
|
||||
![][2]
|
||||
|
||||
[2]: /images/hosting-and-deployment/hosting-on-bitbucket/bitbucket-blog-post.png
|
||||
|
||||
|
||||
## Suggested next steps
|
||||
|
||||
The code for this example can be found in this Bitbucket [repository](https://bitbucket.org/dundonian/hugo-docs-test). Aerobatic also provides a number of additional [plugins](https://www.aerobatic.com/docs) such as auth and redirects that you can use for your Hugo site.
|
@ -2,14 +2,193 @@
|
||||
title: Hosting on GitHub
|
||||
linktitle: Hosting on GitHub
|
||||
description:
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
date: 2014-03-21
|
||||
publishdate: 2014-03-21
|
||||
lastmod: 2017-02-01
|
||||
categories: [hosting and deployment]
|
||||
tags: [github,git,deployment,hosting]
|
||||
authors: [Spencer Lyon, Gunnar Morling]
|
||||
weight:
|
||||
draft: false
|
||||
toc: false
|
||||
aliases: []
|
||||
toc: true
|
||||
aliases: [/tutorials/github-pages-blog/]
|
||||
needsreview: true
|
||||
notesforauthors:
|
||||
---
|
||||
---
|
||||
|
||||
*This tutorial was contributed by [Spencer Lyon](http://spencerlyon.com/) (Personal/Organization Pages) and [Gunnar Morling](https://github.com/gunnarmorling/).*
|
||||
|
||||
## Introduction
|
||||
|
||||
This tutorial describes how to deploy your Hugo based website to [GitHub pages](https://pages.github.com/).
|
||||
|
||||
The following sections are based on the assumption that you are working with a "Project Pages Site".
|
||||
This means that you'll have your Hugo sources and the generated HTML output within a single repository
|
||||
(in contrast, with a "User/Organization Pages Site", you'd have one repo for the sources and another repo for the published HTML files;
|
||||
refer to the [GitHub Pages docs](https://help.github.com/articles/user-organization-and-project-pages/) to learn more).
|
||||
|
||||
## Deployment via _/docs_ folder on master branch
|
||||
|
||||
[As described](https://help.github.com/articles/configuring-a-publishing-source-for-github-pages/#publishing-your-github-pages-site-from-a-docs-folder-on-your-master-branch) in the GitHub Pages docs, you can deploy from a folder called _docs_ on your master branch.
|
||||
This requires to change the Hugo publish directory in the site config (e.g. _config.toml_):
|
||||
|
||||
publishDir: "docs"
|
||||
|
||||
After running `hugo`, push your master branch to the remote repo and choose the _docs_ folder as the website source of your repo
|
||||
(in your GitHub project, go to "Settings " -> "GitHub Pages" -> "Source" -> Select "master branch /docs folder").
|
||||
If that option isn't enabled, you likely haven't pushed your _docs_ folder yet.
|
||||
|
||||
This is the simplest approach but requires the usage of a non-standard publish directory
|
||||
(GitHub Pages cannot be configured to use another directory than _docs_ currently).
|
||||
Also the presence of generated files on the master branch may not be to eveyone's taste.
|
||||
|
||||
## Deployment via gh-pages branch
|
||||
|
||||
Alternatively, you can deploy site through a separate branch called "gh_pages".
|
||||
That approach is a bit more complex but has some advantages:
|
||||
|
||||
* It keeps sources and generated HTML in two different branches
|
||||
* It uses the default _public_ folder
|
||||
* It keeps the histories of source branch and gh-pages branch fully separated from each other
|
||||
|
||||
### Preparations
|
||||
|
||||
These steps only need to be done once (replace "upstream" with the name of your remote, e.g. "origin"):
|
||||
First, add the _public_ folder to _.gitignore_ so it's ignored on the master branch:
|
||||
|
||||
echo "public" >> .gitignore
|
||||
|
||||
Then initialize the gh-pages branch as an empty [orphan branch](https://git-scm.com/docs/git-checkout/#git-checkout---orphanltnewbranchgt):
|
||||
|
||||
git checkout --orphan gh-pages
|
||||
git reset --hard
|
||||
git commit --allow-empty -m "Initializing gh-pages branch"
|
||||
git push upstream gh-pages
|
||||
git checkout master
|
||||
|
||||
### Building and Deployment
|
||||
|
||||
Now check out the gh-pages branch into your _public_ folder, using git's [worktree feature](https://git-scm.com/docs/git-worktree)
|
||||
(essentially, it allows you to have multiple branches of the same local repo to be checked out in different directories):
|
||||
|
||||
rm -rf public
|
||||
git worktree add -B gh-pages public upstream/gh-pages
|
||||
|
||||
Regenerate the site using Hugo and commit the generated files on the gh-pages branch:
|
||||
|
||||
hugo
|
||||
cd public && git add --all && git commit -m "Publishing to gh-pages" & cd ..
|
||||
|
||||
If the changes in your local gh-pages branch look alright, push them to the remote repo:
|
||||
|
||||
git push upstream gh-pages
|
||||
|
||||
After a short while you'll see the updated contents on your GitHub Pages site.
|
||||
|
||||
### Putting it into a script
|
||||
|
||||
To automate these steps, you can create a script _scripts/publish_to_ghpages.sh_ with the following contents:
|
||||
|
||||
```
|
||||
#!/bin/sh
|
||||
|
||||
DIR=$(dirname "$0")
|
||||
|
||||
cd $DIR/..
|
||||
|
||||
if [[ $(git status -s) ]]
|
||||
then
|
||||
echo "The working directory is dirty. Please commit any pending changes."
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
echo "Deleting old publication"
|
||||
rm -rf public
|
||||
mkdir public
|
||||
git worktree prune
|
||||
rm -rf .git/worktrees/public/
|
||||
|
||||
echo "Checking out gh-pages branch into public"
|
||||
git worktree add -B gh-pages public upstream/gh-pages
|
||||
|
||||
echo "Removing existing files"
|
||||
rm -rf public/*
|
||||
|
||||
echo "Generating site"
|
||||
hugo
|
||||
|
||||
echo "Updating gh-pages branch"
|
||||
cd public && git add --all && git commit -m "Publishing to gh-pages (publish.sh)"
|
||||
```
|
||||
|
||||
This will abort if there are pending changes in the working directory and also makes sure that all previously existing output files are removed.
|
||||
Adjust the script to taste, e.g. to include the final push to the remote repository if you don't need to take a look at the gh-pages branch before pushing. Or adding `echo yourdomainname.com >> CNAME` if you set up for your gh-pages to use customize domain.
|
||||
|
||||
## Deployment with Git 2.4 and earlier
|
||||
|
||||
The `worktree` command was only introduced in Git 2.5.
|
||||
If you are still on an earlier version and cannot update, you can simply clone your local repo into the _public_ directory, only keeping the gh-pages branch:
|
||||
|
||||
git clone .git --branch gh-pages public
|
||||
|
||||
Having re-generated the site, you'd push back the gh-pages branch to your primary local repo:
|
||||
|
||||
cd public && git add --all && git commit -m "Publishing to gh-pages" && git push origin gh-pages
|
||||
|
||||
The other steps are the same as with the worktree approach.
|
||||
|
||||
## Hosting Personal or Organization Pages
|
||||
|
||||
As mentioned [in this GitHub's article](https://help.github.com/articles/user-organization-and-project-pages/), besides project pages, you may also want to host a user/organization page. Here are the key differences:
|
||||
|
||||
> - You must use the `username.github.io` naming scheme.
|
||||
> - Content from the `master` branch will be used to build and publish your GitHub Pages site.
|
||||
|
||||
It becomes much simpler in that case: we'll create two separate repos, one for Hugo's content, and a git submodule with the `public` folder's content in it.
|
||||
|
||||
### Step-by-step Instructions
|
||||
|
||||
1. Create on GitHub `<your-project>-hugo` repository (it will host Hugo's content)
|
||||
2. Create on GitHub `<username>.github.io` repository (it will host the `public` folder: the static website)
|
||||
3. `git clone <<your-project>-hugo-url> && cd <your-project>-hugo`
|
||||
4. Make your website work locally (`hugo server -t <yourtheme>`)
|
||||
5. Once you are happy with the results, <kbd>Ctrl</kbd>+<kbd>C</kbd> (kill server) and `rm -rf public` (don't worry, it can always be regenerated with `hugo -t <yourtheme>`)
|
||||
6. `git submodule add -b master git@github.com:<username>/<username>.github.io.git public`
|
||||
7. Almost done: add a `deploy.sh` script to help you (and make it executable: `chmod +x deploy.sh`):
|
||||
|
||||
```
|
||||
#!/bin/bash
|
||||
|
||||
echo -e "\033[0;32mDeploying updates to GitHub...\033[0m"
|
||||
|
||||
# Build the project.
|
||||
hugo # if using a theme, replace by `hugo -t <yourtheme>`
|
||||
|
||||
# Go To Public folder
|
||||
cd public
|
||||
# Add changes to git.
|
||||
git add -A
|
||||
|
||||
# Commit changes.
|
||||
msg="rebuilding site `date`"
|
||||
if [ $# -eq 1 ]
|
||||
then msg="$1"
|
||||
fi
|
||||
git commit -m "$msg"
|
||||
|
||||
# Push source and build repos.
|
||||
git push origin master
|
||||
|
||||
# Come Back
|
||||
cd ..
|
||||
```
|
||||
7. `./deploy.sh "Your optional commit message"` to send changes to `<username>.github.io` (careful, you may also want to commit changes on the `<your-project>-hugo` repo).
|
||||
|
||||
That's it! Your personal page is running at [http://username.github.io/](http://username.github.io/) (after up to 10 minutes delay).
|
||||
|
||||
## Using a custom domain
|
||||
|
||||
If you'd like to use a custom domain for your GitHub Pages site, create a file _static/CNAME_ with the domain name as its sole contents.
|
||||
This will put the CNAME file to the root of the published site as required by GitHub Pages.
|
||||
|
||||
Refer to the [official documentation](https://help.github.com/articles/using-a-custom-domain-with-github-pages/) for further information.
|
@ -1,15 +1,78 @@
|
||||
---
|
||||
title: Hosting on GitLab
|
||||
linktitle:
|
||||
linktitle: Hosting on GitLab
|
||||
description:
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-02-01
|
||||
date: 2016-06-23
|
||||
publishdate: 2016-06-23
|
||||
lastmod: 2016-06-23
|
||||
categories: [hosting and deployment]
|
||||
tags: [hosting,deployment]
|
||||
tags: [hosting,deployment,git,gitlab]
|
||||
authors: [Riku-Pekka Silvola]
|
||||
weight:
|
||||
draft: false
|
||||
toc: false
|
||||
aliases: []
|
||||
toc: true
|
||||
needsreview: true
|
||||
aliases: [/tutorials/hosting-on-gitlab/]
|
||||
notesforauthors:
|
||||
---
|
||||
---
|
||||
|
||||
|
||||
[GitLab](https://gitlab.com/) makes it incredibly easy to build, deploy, and host your Hugo website.
|
||||
|
||||
## Assumptions
|
||||
|
||||
* Working familiarity with Git for version control
|
||||
* Completion of the [Quick Start][quickstart]
|
||||
* A [GitLab account](https://gitlab.com/users/sign_in)
|
||||
* A Hugo website on your local machine that you are ready to publish
|
||||
|
||||
## Create .gitlab-ci.yml
|
||||
|
||||
```bash
|
||||
cd your-hugo-site
|
||||
```
|
||||
|
||||
In the root directory of your Hugo site, create a `.gitlab-ci.yml` file. The `.gitlab-ci.yml` configures the GitLab CI on how to build your page. Simply add the content below.
|
||||
|
||||
```yml
|
||||
image: publysher/hugo
|
||||
|
||||
pages:
|
||||
script:
|
||||
- hugo
|
||||
artifacts:
|
||||
paths:
|
||||
- public
|
||||
only:
|
||||
- master
|
||||
```
|
||||
|
||||
## Push Your Hugo Website to GitLab
|
||||
|
||||
Next up, create a new repository on GitLab. It is *not* necessary to set the repository public. In addition, you might want to add `/public` to your .gitignore file, as there is no need to push compiled assets to GitLab.
|
||||
|
||||
```bash
|
||||
# initialize new git repository
|
||||
git init
|
||||
|
||||
# add /public directory to our .gitignore file
|
||||
echo "/public" >> .gitignore
|
||||
|
||||
# commit and push code to master branch
|
||||
git add .
|
||||
git commit -m "Initial commit"
|
||||
git remote add origin https://gitlab.com/YourUsername/your-hugo-site.git
|
||||
git push -u origin master
|
||||
```
|
||||
|
||||
## Wait for Your Page to be Built
|
||||
|
||||
That's it! You can now follow the CI agent building your page at https://gitlab.com/YourUsername/your-hugo-site/pipelines.
|
||||
|
||||
After the build has passed, your new website is available at `https://YourUsername.gitlab.io/your-hugo-site/`.
|
||||
|
||||
## Next Steps
|
||||
|
||||
GitLab supports using custom CNAME's and TLS certificates. For more details on GitLab Pages, see [https://about.gitlab.com/2016/04/07/gitlab-pages-setup/](https://about.gitlab.com/2016/04/07/gitlab-pages-setup/).
|
||||
|
||||
[quickstart]: /getting-started/quick-start/
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 122 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |