How to deploy your static website easily with gitlab

For some very simple projects we wanted ensure, that we can use git as we do it in nearly every project.


  • Project managed with Git
  • Gitlab CE / EE


  • Branch based deployment
  • Master branch should be published for production
  • Other branches should be deployed as well, but in other folder like builds/{branch}
  • Website users should not see the subfolders if they visit the website

Basicly we manage our projects like in git flow, but any branch based way of using git should be sufficient.

  1. Create a new Projekt in Gitlab
  2. Add your files to Git-Repository
  3. Add pscss to your project or install it centrally on your server git server, alternatively you can also use npm with gulp to compile the scss files to css files
  4. Define the Build Variable CREDENTIALS in the Settings of the Projekt


  1. Add the following .gitlab-ci.yml file
  - deploy
    - Resources/Private/tools/bin/pscss Resources/Private/codeon/scss/style.scss > Resources/Public/css/style.css
    - lftp -e "mirror --exclude ^\.git.* --exclude ^Resources/Private/ --exclude \.gitlab-ci.yaml -eRv  $CI_PROJECT_DIR builds/$CI_BUILD_REF_NAME; quit;" sftp://$CREDENTIALS
    - local

To get the full functionality you should change the pathes in the .gitlab-ci.yml file or follow the file structure suggested by TYPO3.Flow.

Additionally we use npm with gulp to compile the files locally. On the Server we often use pscss to compile the files.

The result of this recipe is the following folder structure on the on the webserver:

ftp-root builds master development otherBranch ...

Now we need to add two more files

  1. .htaccess to redirect the requests to the ftp-root / document root folder into the builds/master folder

RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*?)/?$ /builds/master/$1 [L] RewriteRule ^$ /index.html [R=301,L]

  1. robots.txt which includes directives to avoid indexing the folders, which are not master User-agent: * Disallow: /builds/