alexkorban / elmstatic

Elm-to-HTML static site generator
GNU General Public License v3.0
196 stars 7 forks source link

Create templates for building on GitLab and GitHub pages #6

Closed heyakyra closed 5 years ago

heyakyra commented 5 years ago

The current instructions to get started with Elmstatic nicely build a site which can then be uploaded to a static site host: https://korban.net/elm/elmstatic/

I think this requires that the built site files be committed and uploaded, rather than having just the code itself uploaded and having the CI build it appropriately. Would it be possible to publish starter templates for GitLab/GitHub pages to do this (either in separate repos, or with a page documenting a working config file as Hugo does)?

I'm new to Elm and Elmstatic but I would like to be able to manage it with Netlify CMS and host it on GitLab pages. The documentation for the former now lists Elmstatic after I created a merge request to do so! Hopefully that brings more attention to Elm and Elmstatic from Netlify CMS users :slightly_smiling_face:

alexkorban commented 5 years ago

Thanks for adding Elmstatic to the docs!

I haven't used Netlify or GitLab, so could you please clarify the difference between Netlify and Netlify CMS for me? I had the impression that the output of Elmstatic could be hosted on Netlify the hosting platform (by connecting to a repo on GitHub or GitLab). But how does Netlify CMS fit into this? What does it do with the static files?

heyakyra commented 5 years ago

You're welcome! I hope more people start using it.

Netlify is a hosting platform, but Netlify CMS is an open source CMS that can integrate with static site generators to manage the content (markdown files, etc) in a friendly way to non-coders. But Netlify CMS isn't relevant to this, I was just oversharing my motivations, so for the bug report just ignore the last paragraph sorry!

heyakyra commented 5 years ago

This took me forever to figure out due to this caching issue: https://github.com/elm/compiler/issues/1845

but I believe the .gitlab-ci.yml file should look like this for deploying to GitLab:

image: node:current

pages:
  cache:
    paths:
    - node_modules
    - /root/.elm
    - elm-stuff
  script:
  - npm install -g elm --unsafe-perm=true
  - npm install -g elmstatic
  - elmstatic
  - mv _site public
  artifacts:
    paths:
      - public
  only:
    - master

also make sure .gitignore includes:

elm.js
elm-stuff/
_site/
alexkorban commented 5 years ago

Nice! What would be useful for me to do? Should I include this file in the repo, or show it in the docs?

By the way, Elmstatic could generate the site directly in public by setting outputDir: public in config.json. Then the mv step would not be needed (but of course people would need to update config.json appropriately).

heyakyra commented 5 years ago

Nice! What would be useful for me to do? Should I include this file in the repo, or show it in the docs?

Probably not worth adding files that not everyone needs to the repo, but either:

would be good!

By the way, Elmstatic could generate the site directly in public by setting outputDir: public in config.json. Then the mv step would not be needed (but of course people would need to update config.json appropriately).

Oh, thanks! Very useful, although I'm not sure what the best approach is (minimal changes to Elmstatic defaults vs minimal steps for GitLab CI)

alexkorban commented 5 years ago

Ok, will add it to the docs.

alexkorban commented 5 years ago

Added a Deployment section to the docs: https://korban.net/elm/elmstatic/ Thank you @heyakyra!