DocC and Netlify

dl on Sep 8, 2021

On a previous post I discussed how to merge a DocC documentation archive into a SwiftySites-generated website.

Now Apple provides some guidelines on how to make the exported site play nice with your web server using rewrites.

But with static sites it is common not to have such control over the server side. We instead prefer services like GitHub Pages and Netlify which is the one used by this page.

There is already a great write-up on how to integrate DocC with Netlify. I had to make a few tweaks here and there but the solution pretty much worked seamessly.

Finally here's the resulting configuration used to host SwiftySites's own DocC documentation.

netlify.toml
[[redirects]]
from = "/documentation/*"
status = 200
to = "/SwiftySites.doccarchive/index.html"

[[redirects]]
from = "/tutorials/*"
status = 200
to = "/SwiftySites.doccarchive/index.html"

[[redirects]]
from = "/data/documentation.json"
status = 200
to = "/SwiftySites.doccarchive/data/documentation/root.json"

[[redirects]]
from = "/css/*"
status = 200
to = "/SwiftySites.doccarchive/css/:splat"

[[redirects]]
from = "/data/*"
status = 200
to = "/SwiftySites.doccarchive/data/:splat"

[[redirects]]
from = "/downloads/*"
status = 200
to = "/SwiftySites.doccarchive/downloads/:splat"

[[redirects]]
from = "/images/*"
status = 200
to = "/SwiftySites.doccarchive/images/:splat"

[[redirects]]
from = "/img/*"
status = 200
to = "/SwiftySites.doccarchive/img/:splat"

[[redirects]]
from = "/index/*"
status = 200
to = "/SwiftySites.doccarchive/index/:splat"

[[redirects]]
from = "/js/*"
status = 200
to = "/SwiftySites.doccarchive/js/:splat"

[[redirects]]
from = "/videos/*"
status = 200
to = "/SwiftySites.doccarchive/videos/:splat"

[[redirects]]
from = "/metadata.json"
status = 200
to = "/SwiftySites.doccarchive/metadata.json"

[[redirects]]
from = "/theme-settings.json"
status = 200
to = "/SwiftySites.doccarchive/theme-settings.json"