The current stable main
version is deployed at https://delphi.cmu.edu and https://cmu-delphi-main.netlify.app/.
The next dev
version is deployed at https://staging.delphi.cmu.edu/ and https://dev--cmu-delphi-main.netlify.app/.
This site is based on Hugo and uses Prettier for formatting.
The main content is in the /content
directory written in Markdown or RMarkdown for blog posts.
In addition to the Markdown content frontmatter with YAML syntax is used at the beginning of the file to customize and describe the content. Common fields include title
and description
.
However, depending on the file it can have additional fields. For example for blog posts additional fields are used to list the authors, hero images, summaries, tags, and so on.
Hugo uses so called shortcodes for embedding logic into Markdown files. A good example is linking to other pages.
A relative reference to another page can be created using the relref
shortcode. The argument is the filename with an optional #
anchor to jump to a specific section.
Examples
national daily survey]({{< relref "ctis">}})
[syndromic COVID-19 indicator based on doctor visits]({{< relref "2020-10-14-dv-signal" >}})
[self-reported symptoms]({{< relref "2020-08-26-fb-survey#whats-in-the-survey" >}})
Instead of a direct link to the API reference there is the apiref
shortcode. The advantage is that it is easy to later change the API base URL without changing each appearance. The argument is the path segment to point to.
Examples
[public API]({{< apiref "api/covidcast.html" >}})
[Epidata API]({{< apiref "/" >}})
In RMarkdown things are slightly more different since the R Markdown parser is used before Hugo takes over. Blogdown has a special function for handling shortcodes: blogdown::shortcode_html
.
Examples
`r blogdown::shortcode_html("reflink", "2020-08-26-fb-survey", "Facebook")`
`r blogdown::shortcode_html("reflink", "2020-08-26-fb-survey#some-interesting-examples", "previous exploratory investigations")`
`r blogdown::shortcode_html("apireflink", "api/covidcast.html", "public API")`
npm install
npm start
to create a development Hugo server running at http://localhost:1313npm run format
to run prettier and format filesnpm run build
to build a minified build in /public
In addition the blog is written in RMarkdown using Blogdown. In order to convert the Rmd files to HTML files for Hugo you also need to:
conda env create -f environment.yml
which will installconda activate www-main
Rscript ./dependencies.R
As an alternative you can use Docker and Docker Compose:
docker-compose up -d
to create a docker container for the current environment.docker-compose exec r bash
to jump into the container. micromamba activate www-main
to activate the environmentexport API_KEY=y0urAp1kEy
to add your own api key as env variable.Now you have the environment ready to start converting .Rmd blog files to html.
Rscript -e 'blogdown::build_site(local=TRUE, run_hugo=FALSE, build_rmd=TRUE)'
local=TRUE
similar to -D
to process draft filesrun_hugo=FALSE
to manually run hugobuild_rmd=TRUE
force a (re)build of the Rmd pagesRscript -e 'blogdown::build_site(local=TRUE, run_hugo=FALSE, build_rmd="content/blog/<NAME>.Rmd")'
where <NAME>
should be replaced by the name of the Rmd file.npm run build:blog
blogdown also has an integrated server blogdown::serve_site()
which will render RMarkdown files on the fly and does a similar thing as hugo server -D
.
A shortcut is available through npm run start:blog
.
Prerequisite: Installed Blog Editor environment from the previous section
Create a new file content/blog
with a naming convention of YYYY-MM-DD-short-title.Rmd
. The date is the creation date. Copy the template post or another example to start with. Note: Starting the file with an underscore (e.g. _2021-04-20-jj-vaccine.Rmd
), will stop this file from being automatically checked by the Github Action CI. Only do this when the public CI cannot build this post, if for example private data is used.
In case you use new dependencies don't forget to either edit environment.yml
or dependencies.R
.
A Github action should run when Rmd files changes so it will verify that the blog post can be built.
However, the converted HTML file along with all generated images are committed to the repository.
This simplifies the deployment and ensures that we have a blog post even when the API or data changes.
The header of a blog file contains numerous attributes to be defined, including: name, publication date (date
), tags, a short summary (at most 150 characters), and a list of authors. The author list authors
is a list of people keys, see below for how to add people.
The heroImage
is an optional hero image banner. The image is optional but its thumbnail version is not. However, the template post has good default value for this one. The hero image should be a JPG file with 1120x440 pixels. The thumbnail hero image should be a JPG file with 300x300 pixels. The files should be stored in /content/blog/images
.
The related
list is a list of related blog links identified by their file name without the Rmd suffix.
In order to generate links that are relative to the whole website there are two short codes for R Markdown available.
using the reflink
shortcode. For example, r blogdown::shortcode_html("reflink", "2020-09-18-google-survey", "Google")
will generate a relative link to the blog post with the filename 2020-09-18-google-survey
and anchor text Google
.
using the apireflink
shortcode. For example, r blogdown::shortcode_html("apireflink", "api/covidcast.html", "COVIDcast API")
will generate a link to the API docs and its sub page api/covidcast.html
and will look like: COVIDcast API
.
In case of a wide figure, one can break out of the layout by adding the out.extra = 'class="wide-figure"'
extra argument to the corresponding R chunk.
e.g.,
{r, message = FALSE, warning = FALSE, fig.width = 9, fig.height = 5, out.extra = 'class="wide-figure"'}
ggplot(...)
Static images (e.g. pre-generated plots) should be stored in a /static/blog/<BLOGFILE_NAME>_files
directory and referenced using something like
![](/blog/2021-04-29-vaccine-trends-hispanic_files/hesitancy_over_time_hispanic_and_white_adults.png)
see before using Rscript -e 'blogdown::build_site(local=TRUE, run_hugo=FALSE, build_rmd="content/blog/<NAME>.Rmd")'
where <NAME>
should be replaced by the name of the Rmd file. The generated files should be committed to this repository to ensure reproducibility.
People on this website are centrally managed in the /content/people/index.md
file. Each entry should have the following attributes:
key
... short key to identify this person when referencing them in the blog sectionfirstName
, lastName
, affiliation
image
... name of the head shot image (preferred 250x250px in JPG format) stored in /content/people/headshots
description
... used within the blog footer as an about the author textnote
...optional note about past contributorslink
... optional used for linking to a personal websiteteam
... list of teams this person is part of. used to assign places on the teams page. possible values are:
core
... core memberblog
... blog authorhighlight
... highlight person on front pageexternal
... external person not to be listed in the teams pagepast
... past member team sectionleadership
... ryan and ronicontributors
... contributor team sectiongoogle
... google team sectionThe current core+leadership montage (often used in external talks) is available from an unlinked page at /about/montage/.
News items are short announcements that should be persistent. The are centrally managed in the /content/news/headless
directory. Each news item is its own file with content, title, and publication date.
The website is configured to automatically resize images for optimized page load times. However, starting with a proper aspect ratio is essential.
"Artifacts" are undesirable blurry or blocky areas of an image created during resizing or compression. The presence and impact of artifacts can be affected by multiple factors, including the original size (greater size difference to target -> more artifacts), but also the actual content of the image (slow gradients next to areas of high contrast are particularly bad). You can reduce or avoid artifacts by choosing an image which is closer to its target size, or swapping in an image with more background texture.
Following images size and aspect ratios are used:
Image Type | Preferred Size | Aspect Ratio | Target Width |
---|---|---|---|
Landing Page Banner | 1440x500 | 2.88:1 | 1440px |
Team Member | 250x250 | 1:1 | 250px |
Blog Banner | 1120x440 | 2.5:1 | 1120px |
Blog Teaser | 300x300 | 1:1 | 300px |
Research Paper Teaser | 300x300 | 1:1 | 300px |
Latest Card Teaser | 300x300 | 1:1 | 300px |
News Item Teaser | 300x300 | 1:1 | 300px |
The release consists of multiple steps which can be all done via the GitHub website:
Run workflow
button. Enter the next version number or one of the magic keywords (patch, minor, major) and hit the green Run workflow
button.