Using Pelican to deploy static website in Gitlab
Static Website hosting on gitlab
I my last article I wrote about gitlab pages. This article is a quick note on how to deploy your static blog using pelican.
This is a more developer / computer known person prespective. If something goes wrong do ping me
- Sign up for an account at gitlab.com
- Create a new project called blog.
- Open the GNU/Linux terminal and follow the steps.
- sudo dnf install python-pip (Fedora) or sudo apt-get install python-pip (Debian)
- sudo pip install virtualenv
- cd ~/Documents
- git clone https://gitlab.com/your_username/blog.git
- virtualenv blog
- cd blog
- source bin activate
- pip install pelican markdown
- pelican-quickstart .Once you hit this command,enter the details of your site name and description. Go with the defaults for the rest of the things.
- cd content
- create a file called first-blog.md (or any name). Write content following this pattern http://docs.getpelican.com/en/3.6.3/content.html
- cd ../
- type the command "pelican" . Once this command is done, you should have a folder called output. If that has generated, proceed, else hold up and cross check any errors or missed steps.
- create a file called .gitlab-ci.yml and enter the following contents in it. """ pages: stage: deploy script:
- mkdir .public
- cp -r output/* .public
- mv .public public artifacts: paths:
- public only:
- master """
- git add .
- git commit -m "Blog on gitlab"
- git push
You are done. If all go good, you should see the build starting in your projects build page.
Now sit back and relax until the build completes. Once done, you should see your website live at your-username.gitlab.io/blog
If you are looking for a ready repo, have a look at the sample repo I have put up
I also have a sample blog running here
If you have written it better, send me a PR :-)