Swiftpack.co - Package - SDGGiesbrecht/SDGWeb

macOS • Windows • Web • CentOS • Ubuntu • tvOS • iOS • Android • Amazon Linux • watchOS



SDGWeb provides tools for generating websites.

כְּשִׁמְךָ אֱלֹהִים כְּן תְּהלָּתְךָ עַל־קַצְוֵי־אֶרֶץ׃

Like your name, O God, your praise reaches to the ends of the earth.

―sons of קורח/Koraẖ


  • Sites are constructed from simple templates.
  • Customizable template processing in Swift.
  • Supports localized websites.

Example Usage

let mock = RepositoryStructure(
    .appendingPathComponent("Mock Projects")

let site = Site<L, Unfolder>(
  repositoryStructure: mock,
  siteRoot: UserFacing<URL, L>({ _ in return URL(string: "http://example.com")! }),
  localizationDirectories: UserFacing<StrictString, L>({ localization in
    return localization.icon ?? StrictString(localization.code)
  author: UserFacing<ElementSyntax, L>({ _ in
    return .author("John Doe", language: InterfaceLocalization.englishCanada)
  reportProgress: { _ in }

try site.generate().get()
let warnings = site.validate()


SDGWeb provides libraries for use with the Swift Package Manager.

Simply add SDGWeb as a dependency in Package.swift and specify which of the libraries to use:

let package = Package(
  name: "MyPackage",
  dependencies: [
      name: "SDGWeb",
      url: "https://github.com/SDGGiesbrecht/SDGWeb",
      from: Version(5, 5, 0)
  targets: [
      name: "MyTarget",
      dependencies: [
        .product(name: "SDGWeb", package: "SDGWeb"),
        .product(name: "SDGHTML", package: "SDGWeb"),
        .product(name: "SDGCSS", package: "SDGWeb"),

The modules can then be imported in source files:

import SDGWeb
import SDGHTML
import SDGCSS


The SDGWeb project is maintained by Jeremy David Giesbrecht.

If SDGWeb saves you money, consider giving some of it as a donation.

If SDGWeb saves you time, consider devoting some of it to contributing back to the project.

Ἄξιος γὰρ ὁ ἐργάτης τοῦ μισθοῦ αὐτοῦ ἐστι.

For the worker is worthy of his wages.



Stars: 1


Used By

Total: 0


Version 5.5.0 -

New Features

  • Less of the API is disabled on the web platform (because parts of Foundation are now available).

Version 5.4.2 -

Bug Fixes

  • The API has been updated to use #filePath.
  • Android detects dead links just like other platforms.

Version 5.4.1 -

Bug Fixes

  • Swift 5.3 (Older toolchains will not select this version.)

Version 5.4.0 -

New Features

  • CentOS and Amazon Linux are now supported.

Version 5.3.1 -

Bug Fixes

  • Dependencies have been updated.

Version 5.3.0 -

Breaking Changes

  • Swift 5.2 (Older Swift toolchains will not resolve this version.)

New Features

  • Site generation formats the template files as well as the resulting output (unless disabled).
  • DocumentSyntax conforms to FileConvertible and Equatable.
  • ElementSyntax has a new heading factory.

Version 5.2.0 -

New Features

  • Web is now supported (as a platform). Actual runtime stability depends on the toolchain used to compile the package.

Version 5.1.2 -

Bug Fixes

  • Minor internal optimizations.

Version 5.1.1 -

Bug Fixes

  • Minor internal optimizations.

Version 5.1.0 -

New Features

  • Windows and Android are supported. Actual runtime stability depends on the toolchain used to compile the package.

Version 5.0.1 -

Bug Fixes

  • Redirects ignored by the browser display in readable form (without percent encoding).

Version 5.0.0 -

Breaking Changes

  • Site generation and its API replace many uses of strings with direct use of syntax nodes.
    • Instead of a frame and a string processor, sites now use syntax unfolders. Arbitrary reusable components (including frames) can be implemented using custom unfolders. See the “New Features” section for more information.
    • Metadata is no longer a separate comment. It is now supplied using attributes on the root element. The root element should usually be <page> or something that unfolds into (and through) it.
    • Localization is now a phase of syntax unfolding: <localized><en>English</en><fr>Français</fr></localized>. The old style ([* English */* Français *]) is no longer supported.
  • Redirect has been replaced with a factory method: DocumentSyntax.redirect(language:target:).
  • AttributedSyntax’s class: String? property has been changed to classes: [String].

New Features

  • ElementSyntax has convenient factory methods for constructing common elements.
  • Syntax nodes can be “unfolded”. Custom unfolders can be set up to unfold custom pseudo‐elements into standard HTML. These can be used to create reusable shorthand for more complicated elements. For example, the default unfolder contains a rule that changes <foreign>...</foreign> into <span class="foreign">...</span>.

Bug Fixes

  • The root CSS styles handle more:
    • Paragraphs use book style by default (unspaced, indented, justified and hyphenated).
    • Print media adjusts links:
      • Links are not highlighted.
      • Navigation blocks are removed.
  • Unescaping now handles all entities.

Version 4.0.1 -

Dependency updates.

Version 4.0.0 -

Breaking Changes

  • ElementSyntax.name has been changed to nameText, and name now refers to the TokenSyntax instead of the String.

New Features

  • Syntax nodes have more convenience methods and properties.
  • Consistent formatting can be applied to syntax nodes with format().
    • Formatting is applied by default during site generation. It can be disabled by setting the new parameter of generate(formatting:) to false.

Bug Fixes

  • Validation now flags heading levels that are skipped. (Such as having an h5 without an h4.)

Version 3.1.0 -

New Features

  • All platform restrictions have been removed.

Version 3.0.0 -

Breaking Changes

  • Swift 5.1
  • The older ContentSyntax and its child list node have been collapsed into a single list node.
    • The freed‐up, shorter name has been reused as the new name for ContentElementSyntax.

New Features

  • Many convenience methods and initializers have been added to syntax nodes.

Version 2.0.1 -

Bug Fixes

  • Validation recognizes data- attributes.

Version 2.0.0 -

Breaking Changes

  • Comments are now handled by the syntax tree, resulting in several new enumeration cases.

New Features

  • Validation is available directly without setting up site generation: Site.validate(site:).

Bug Fixes

  • Miscellaneous improvements to validation results.
  • Redirects have improved HTML style.
  • “>” is now escaped. While not technically necessary, this style makes many source operations more reliable.

Version 1.0.2 -

Bug Fixes

  • Interface‐related components are now localized into German.

Version 1.0.1 -

Bug Fixes

  • Dependency updates.

Version 1.0.0 -

Breaking Changes

  • Modules do not export their dependencies. Each must be imported separately.
    • The @_exported attribute was never officially supported by Swift anyway. As the last remaining thing blocking the 1.0.0 release, it was deemed not important enough to delay until official support. Since it is not strictly necessary for any functionality, it has been removed instead of waiting.

Version 0.1.1 -

Bug Fixes

  • HTML parsing correctly handles multi‐scalar clusters.
  • Unicode characters are properly accepted in URLs.

Version 0.1.0 -

Initial release.

Version 0.0.3 -

Third pre‐release.

Version 0.0.2 -

Second pre‐release.

Version 0.0.1 -

Initial pre‐release.