Automating Swift Site Generation on Netlify #3
diegolavalledev
announced in
Posts
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Originally published on diegolavalle.com.
Having used GitHub Pages and Jekyll for my hosting needs I eventually switched to Hugo and Netlify. I enjoy the advanced capabilities the latter has to offer such as branch deploys and branch subdomains both of which I have been taking advantage of extensively.
Recently I decided to move away from Hugo since I'm not truly well-versed in the Go language and so I created a static site generator based on Swift. In a nutshell SwiftySites consists of an SPM package that is added as dependency to an executable target which in turns outputs the website's files.
To produce a local version of the site you simply run the project on Xcode or instead issue
swift runon the command line. The second alternative is also good for the open source version of the compiler which is also available on Linux systems.If our goal is to generate a production-ready version we should then tweak that command to make sure it picks up the right configuration and also clears the output folder
wwwbefore writing into it again.So to have Netlify automatically build and publish our site we must provide our custom command in
netlify.tomlat the root of our repository so that we don't get stuck with the defaultswift build. We can optionally specify a preferred version of the toolchain as well.Check out this very site's source code to explore how everything we just discussed ties into the complete solution.
Beta Was this translation helpful? Give feedback.
All reactions