DataONEorg / dataone-web

DataONE static website
Apache License 2.0
2 stars 1 forks source link

🌍 DataONE Static Website

All files used to generate the DataONE static website.

site status url
Main https://www.dataone.org
Preview https://preview.dataone.org

Contributing

Please see the CONTRIBUTING.md file for information on how to contribute to the DataONE website.

Developer guidelines

I. Orientation

The website is generated using the static site generator, Hugo, and the Block, Element, Modifier (BEM) approach to development.

Hugo

Hugo uses a specific directory stucture to organize files. Within this structure, certain files could be stored in either the theme directory (themes/dataone) or the project's root directory (.) and the site would look exactly the same. For instance, a new markdown content file could be placed in either ./content/new-markdown-file.md or ./themes/dataone/content/new-markdown-file.md and the resulting html would be identical. For consistency, we keep content in the root directory and layout and style information in the theme directory. In other words,

Deploying this Hugo site locally

Run

  hugo server -D

and then visit localhost:1313, or whatever baseURL is configured in /config/development/config.yaml

BEM with Hugo

Forestry.io (⚠️ deprecated)

Historically, we uses the git-backed CMS Forestry.io, a service which is no longer available. The content in the .forestry/ directory is no longer used, however, the forestry front matter is basically a schema for each block. It describes each variable used in a block.

II. Block pages

A block is a stand-alone component in the website. Blocks may be simple items, like buttons, or more complex layout components, like a page section. Content editors have the option of creating a page layout using blocks. Pages using the "block" layout store content in the front-matter section of a mark down file, for example:

---
title: Block Test
description: Page description
layout: blocks
page_sections:
  - block: Name of block
    template: template-name
    variable1: Some content
    variable2: Some more content
  - block: Name of the second block
    template: template-name
    variable1: Some content
    variable2: Some more content
---

blocks.html:

{{ $page := .Page }}
{{- define "main" -}}
  {{- range .Params.page_sections -}}
    {{ partial (printf "blocks/%s/%s.html" .template .template) (dict "Section" . "Page" $page ) }}
  {{- end -}}
{{- end -}}

III. Creating a new Block

Blocks require three components: 1) a template, 2) style information, 3) documentation. Optionally, 4) a shortcode file may be created to allow content editors to use the template from within a markdown block.

1. Template

2. Style information

3. Documentation

4. Shortcode (optional)

If the block is a simple one that requires few variables, and if content editors might want to use it within a markdown block, the partial template can be made available by creating a simple shortcode file:

You may also create a snippet for the shortcode, which is basically an example of how the shortcode should be formatted. Forestry makes these snippets available to content editors to insert into the markdown editor. Snippets are stored in the .forestry/snippets/ directory.

The Network Page

Node Organization Based on operationalStatus

Member nodes on the Network page are categorized based on their operationalStatus property in the DataONE registry. The operationalStatus property is a string that can take on one of the following values:

We also recognize a status called deprecated. However, there are multiple reasons a node might be marked as deprecated. For the moment, these nodes are not included on the /network/ page, though we have discussed introducing more specific operationalStatus values to depict different circumstances under which a node might be deprecated. See discussion in issue #176. To make changes to how nodes are categorized, edit the dataone-web file.

Misc. Resources

Inline SVG tips & tricks

We use inline SVG for some imagery on the website, like the header image on the hosted repository page.

Continuous Integration

The site is built using Github Actions, and deployed via rsync using an ssh key that is only accessible by the github build system. The action workflow uses peaceiris/actions-hugo to build the hugo site, and then the DataONE rsync-deploy action to deploy it over rsync to our host infrastructure. This requires that the target host is set up to accept the ssh key as an authorized key. To configure it, I generated an ssh key which is dedicated for just this application, and is not shared or commited to git.

$ ssh-keygen -t rsa -b 4096 -C 'GHA deploy key' -f ./deploy_rsa
$ ssh-copy-id -i deploy_rsa.pub user@deployhost

Set up Secrets variables pointing at the deploy location, in the GitHub repository settings for $HOST, $PORT, $USER, $GROUP, and $KEY. See https://github.com/DataONEorg/rsync-deploy for more details on these secret variables, and how to configure the GHA workflow to deploy files to various target directories. In this case, the workflow is configured to deploy the preview branch to a directory served by https://preview.dataone.org, and the main branch to https://dataone.org.

Credits