Skip to content

Deploying to GitHub and GitLab pagesλ︎

GitHub pages and GitLab pages provide fast and free service for running an HTML website, serving HTML, CSS and JavaScript files.

By placing all the web pages and asset files in a docs directory, these services can be configured to serve those assets publicly.

Create a new build configuration to output the single JavaScript file to the docs directory, typically in a js sub-folder or any preferred directory structure.

Create a file called pages.cljs.edn to represent a new build and add the following configuration

{:main practicalli.hello-world
 :output-to "docs/js/hello-world.js"}

Edit the project deps.edn file and add a new alias to deploy to GitHub/GitLab pages directory

:pages {:main-opts ["-m" "figwheel.main" "-O" "advanced" "-bo" "pages"]}

Create the deployable JavaScript file using the following command:

clojure -M:fig:pages

Copy the /resources/public/index.html and any other web assets to the /docs directory and update the /docs/index.html to refer to the correct location of the JavaScript file generated by Figwheel.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="css/style.css" rel="stylesheet" type="text/css">
    <link rel="icon" href="https://clojurescript.org/images/cljs-logo-icon-32.png">
  </head>
  <body>
    <div id="app">
    </div> <!-- end of app div -->
    <script src="js/hello-world.js" type="text/javascript"></script>
  </body>
</html>

See package a single file for production for more details.