simpleSite is an Ant-based static-site build system for small HCMC websites that do not require large datasets. It was initially created for conference websites, although it may be used for other types of sites in future.
The build reads site-wide configuration from properties.xml, combines well-formed XML content with XHTML boilerplate templates, compiles SCSS, and writes the finished site to the site/ directory. It is written to support both monolingual and multilingual output.
For internal (HCMC) users, please create a new branch for each new site developed using this repo. External users are welcome to fork the repository and use it for their needs
The build requires:
- Java 11 or newer;
- Apache Ant;
- ant-contrib (the build expects
lib/ant-contrib-1.0b3.jar, although it may also be installed in Ant's classpath); - the Saxon HE and VNU Validator JARs referenced in
build.xml; - Dart Sass, available as the
sasscommand; - ImageMagick, available as the
identifycommand; and - a Bash-compatible shell.
The deployment target requires rsync, SSH access, and the appropriate HCMC credentials. The contents of lib/, generated templates, compiled CSS, and the generated site are ignored by Git, so a fresh clone may require the local dependencies to be supplied before it can build.
-
Edit
properties.xmlto describe the site, its languages, navigation, metadata, and asset paths. -
Add or edit page content in
content/. -
Customize the source templates in
boilerplate/and styles inscss/as needed. -
Run the development build:
ant fullBuild
-
Open
site/index.htmlin a browser and review the generated pages.
fullBuild is the default target, so running ant by itself has the same effect. It cleans the existing site/ directory before rebuilding it.
The build is organized around properties.xml. This file contains the language list, site title, contact information, event metadata, navigation, interface labels, image settings, and paths to the site's CSS, JavaScript, favicons, and web manifest.
Define every output language in the <languages> element. Exactly one language should be marked as the default:
<languages>
<lang code="en" label="English" default="true"/>
<lang code="fr" label="Français"/>
</languages>For a monolingual site, a property's text can appear directly inside its element:
<siteTitle>Title of Site</siteTitle>For a multilingual site, put each translation in a child element whose name matches a language code:
<siteTitle>
<en>Title of Site</en>
<fr>Titre du site</fr>
</siteTitle>Provide translations for all user-visible metadata, navigation items, and interface labels. The language marked default="true" becomes the site's default language; if none is marked, the build uses the first language in the list.
To use a language-selection splash page for a multilingual site, uncomment and configure <languageSelector> in properties.xml.
Each navigation entry supplies a target file and a label for every language:
<navigation>
<item href="about.html">
<en>About</en>
<fr>À propos</fr>
</item>
</navigation>Content filenames and navigation href values must agree. The build marks the navigation link for the current page with class="active" and aria-current="page".
Store page content as well-formed XML in content/.
For a monolingual site, place XML files directly in that directory:
content/
├── about.xml
└── schedule.xml
For a multilingual site, create one subdirectory per language and provide a translated version of every page in the corresponding XML files. Corresponding XML files currently need the same filename in every language:
content/
├── en/
│ ├── about.xml
│ └── schedule.xml
└── fr/
├── about.xml
└── schedule.xml
Each file should have a single wrapper element. The wrapper itself is removed and its children are inserted at <?docContent?> in the content-page template. The existing content/about.xml provides a starting example:
<div id="root" xmlns="http://www.w3.org/1999/xhtml">
<h1>About</h1>
<section id="organization">
<h2>Organization</h2>
<p>Page content goes here.</p>
</section>
</div>When a page contains two or more <section> elements, sections that have both an id and a heading are included in an automatically generated secondary navigation menu.
If you wish to modify templates for either the landing/splash page or for content pages you can do some by modifying:
boilerplate/landingPageTemplate.xmlfor the landing/spash page; and/orboilerplate/contentPageTemplate.xmlfor content pages.
Do not edit files in templates/. They are generated from the boilerplate files for each configured language and are overwritten during every build.
Templates can retrieve values from properties.xml in two ways:
- use a processing instruction such as
<?siteTitle?>where elements or text should be inserted; and - use an attribute placeholder such as
href="{?faviconSvg}"where a property should become part of an attribute value.
The <?navigation?> and <?docContent?> processing instructions have special build-time behavior. Other placeholder names are resolved against elements in properties.xml.
- Edit SCSS in
scss/. The build compiles it intocss/and copies the result intosite/css/. - Store shared images in
images/. The image-dimension utility records their dimensions so the XSLT can addwidth,height, and an aspect-ratio class to generated<img>elements. - Store JavaScript in
js/, fonts infonts/, and downloadable PDFs inpdf/. - Supply the primary CSS and JavaScript filenames in
<files>inproperties.xml.
Running a development build (eg. ant fullBuild) retains stable CSS and JavaScript filenames and the CSS source map. A production build (ant productionReady) gives the primary CSS and JavaScript files content-hashed names, removes the source-map reference, and creates site/.htaccess with cache-control rules.
| Command | Purpose |
|---|---|
ant fullBuild |
Clean and rebuild the complete development site, including resources, content pages, landing pages, and the sitemap. |
ant processSingleContent -Dcontent.file=content/about.xml |
Rebuild one page in a monolingual site. |
ant processSingleContent -Dcontent.file=content/fr/about.xml |
Rebuild one page in a multilingual site; the language and output directory are inferred from the path. |
ant validateSite |
Run the VNU Validator over HTML files in site/. Review the console output for errors. |
ant productionReady |
Run a clean production build with cache-busted assets, then validate it. |
ant clean |
Remove generated contents from site/. |
ant rsyncToLiveServer |
Deploy site/ to the configured HCMC server using rsync --delete. |
Additional component targets can be listed with ant -p.
Before producing or deploying a real site:
- Set the public base URL in the
siteUrlparameter inxsl/master_build_sitemap.xsl; it is used in bothsitemap.xmlandrobots.txt. - Review the project name and the destination in
rsyncToLiveServerinbuild.xml. The current destination is derived from the lowercase Ant project name. - Run
ant productionReadyand resolve any validation errors reported in the console. - Inspect the generated
site/directory. - Run
ant rsyncToLiveServeronly when the remote destination is correct. This target uses--delete, so files that exist remotely but not insite/will be removed.
boilerplate/ XHTML page templates
content/ XML page content
fonts/ Web fonts copied to the output
images/ Shared site images
js/ JavaScript copied to the output
lib/ Local Java dependencies
pdf/ Downloadable PDF documents
scss/ Sass source files
site/ Generated website
templates/ Generated language-specific templates
utilities/ Build helper scripts and generated image data
xsl/ XSLT build transforms
build.xml Ant targets and deployment configuration
properties.xml Site-wide configuration and translated interface text
See LICENSE.