Build your Environmental Data Science portfolio

Tell us about yourself and get started with open, reproducible science

Your first project for Stars is also your first step towards becoming an Environmental Data Scientist – building a portfolio website so you can share your work!
Learning Goals:
  • true
  • Build a portfolio website to share your work
  • Get to know each other
  • Explain how web publishing is important for open science
  • Describe the web publishing tool GitHub Pages
  • Name some advantages of GitHub Pages for web publishing
Keywords

Science communication, Internet publishing

Welcome to your first ESIIL Stars Coding Challenge!

When we meet for our in-person Environmental Data Science training, we’d like for all of us to be able to share our websites with each other. You don’t have to have any data science projects on it yet! But, there are a couple of reasons we are assigning this challenge:

  1. It’s a great way to get to know each other! We hope you will show off your creativity and share about yourselves and your community on your website.
  2. Portfolio websites are incredibly valuable when you are looking for jobs or collaborators on data science projects. Anyone can say they know how to code – a portfolio shows it’s true.
  3. Thought it’s not Python, you’ll need to understand some fundamentals about how code works to write your website. Code has a syntax that is more structured than written language, which you’ll be able observe that while using Markdown and HTML. Code is also built to be able to do similar tasks repeatedly by changing parameters. Keep an eye out for these concepts as you work through this challenge!
Try It

Before we meet at our in-person training in Boulder, you will need to:

  1. Build and publish your portfolio page
  2. Write about yourself and your interest in environmental data science
  3. Add at least one image

You can optionally add additional formatting and a theme to your webpage. We’ll work through adding a map to your page together – but you’re welcome to try it out yourself if you need an extra challenge! We’ve provided a lot of resources here to help you, including written descriptions, screenshots, and video demos. However, don’t hesitate to reach out to your faculty or us if you run into a problem.

Get started with open, reproducible science

The internet has revolutionized science publishing. For example, most published scientific papers are now made freely available online within one year (Randall Munroe 2013):

The Rise of Open Science: The accelerating pace of scientific publishing and the rise of open access, as depicted by xkcd.com cartoonist Randall Munroe. Open access reached a tipping point in 2011, when more than half of new research became available freely online.

The Rise of Open Science: The accelerating pace of scientific publishing and the rise of open access, as depicted by xkcd.com cartoonist Randall Munroe. Open access reached a tipping point in 2011, when more than half of new research became available freely online.

It’s not just peer-reviewed publications that have changed – scientists all over the world now use websites, blogs, and social media to discuss, communicate, and publicize their work. The internet is also a great way to transparently involve your community in your research.

Important

Not all science has to be open! It’s important to think about the impacts of publishing your work on people and communities wherever you are studying, and also honor principles data sovereignty. We will talk about some ways to publish your work while omitting or obscuring sensitive details, but for now make sure that you and your mentors are comfortable before putting your work on the internet.

There are lots of tools available for creating free websites. We, as Earth and Environmental Data Scientists, like to use a platform called GitHub Pages for a couple of reasons:

  1. It’s completely free to use, event for larger websites (like this one!).
  2. It is a feature of the code collaboration website GitHub, which is already where most programmers and scientists keep their code. Keeping our websites on GitHub also means that we can collaborate on and discuss them online, the same way we would any other code.
  3. It can automatically build an attractive website using text-based, human-readable tools.
  4. It can automatically incorporate the plots and maps generated by code.
  5. Though GitHub itself is not open source software (it’s owned by Microsoft), Pages is built on open-source tools. This means that if for some reason the availability or pricing structure ever changes we could download the code and put the website up somewhere else.
Check out our demo video!

Check out our explainer video to learn more about what a personal portfolio webpage can do for you, and see some examples from previous students!

INTRO: Portfolio pages by ESIIL

In the following lesson, you will learn how to create a personal portfolio webpage and publish it for free using GitHub Pages.

STEP 1: Create your own portfolio webpage

GitHub is a powerful software development tool owned and operated by Microsoft. It is used almost universally for software development and scientific projects. It lets you:

  • Keep track of all the changes you have ever made, when, and why
  • Collaborate with others
  • Get your code online so you can access it anywhere
  • Use a cloud platform to run your code
  • Publish a website in minutes

We’ll be focusing on that last feature in this activity, in which you will create and publish your own online portfolio website. Read more about git and GitHub in our open Earth Data Science textbook pages.

Check out our demo video!

Follow along with our video demo here:

DEMO: Build your portfolio by ESIIL


STEP 1A: Create a GitHub account

Use this link to create a free GitHub account.

Warning

If you already have a GitHub account, there is no need to create a new account!


STEP 1B: Create a repository

Once you have a GitHub account, get started by creating a new repository for your webpage. There are several ways to accomplish this task.

Warning

Sometimes buttons on GitHub are blue instead of green.

What is a repository?

A GitHub repository is a collection of code, documentation, and configuration files. All changes you make in a repository will be tracked using the version control system git. You can discuss and manage your project’s work within the repository.

To do this you can:

  1. Navigate to your profile page

  2. Click on the dropdown arrow next to your profile photo in the upper right corner

  3. Select Your profile

    Select Your profile
  4. Select the Repositories tab from the menu near the top of the page.

    Select the Repositories tab from the menu near the top of the page.
  5. From here, you can select the green New button on the right to get started.

    Select the green New button on the right to get started
  6. Customize the settings:

    • Give your repository a short and descriptive name. We recommend <yourusername>.github.io because it results in the simplest url for your website.
    • Give your repository a description
    • Make your repository Public
    • You can skip adding the gitignore file for now
    • Add a README so your repository home page (on GitHub, NOT your published website) will include your title and description
    • Choose a License for your repository. Check out choosealicense.com for more information about popular options.
  7. Once you’re done, select the green Create Repository button at the bottom of the page

Speak Code

When reading code snippets, the < and > symbols are usually used to surround text you should replace. Do not leave the < and > symbols in place!. For example, in this case your repository name would be jdoe.github.io, if jdoe was your GitHub username. There’s a BIG exception to this rule when it comes to building websites – < and > are key characters if you are using HTML. Read more about HTML.

Licenses

A license, copyright, and data rights or data sovereignty are all slightly different. A license is about whether and how someone else can use the code in your repository. Copyright is about the text published on your website, and data rights are about whether and how others can use your data


STEP 1C: Create a new index.md file

You will create a new file called index.md that will serve as the content for your webpage. To do this you can :

  1. Select the Add file button from the menu on the right

  2. Select Create new file.

    Select Create new file.
  3. Name your new Markdown file index.md. This will make it the home page of your website. Then, add a Markdown header text to your index file, e.g.

# A fabulous Earth Data Science Portfolio
Note

You can change this text to your name or something else. This is your website, and you’ll always be able to come back and make edits!


STEP 1D: Commit changes

Now that you’ve created your index.md file and added some text, you’ll want to commit changes to your repository. Add an optional extended description of your changes and then select the green Commit changes button at the bottom of the page.

Commit changes

STEP 1E: Build your webpage

Once you’ve created your index.md file you’re ready to build your webpage:

  1. From your repository, select the Settings tab from the right end of the menu.

    Navigate to your repository settings
  2. From here, scroll down the menu on the left and select Pages.

    Select the Pages settings tab
  3. Now you’ll want to select the main option under the Branch heading and then select Save.

    Select the main branch in your repository

STEP 1F: Check on your webpage

Check in on your webpage to see how it is doing by opening the link https://username.github.io/ in a new tab in your web browser. Here, you’ll need to replace username with your GitHub username. Once you see your name (or whatever text you added to your index.md file in Step 2) appear as a Markdown header, then you know your webpage is working!

Note

Sometimes your webpage can take a minute or so to build so be patient and refresh every 30 seconds or so until the page is done building. You can track the progress in the Actions tab.


STEP 1G: Start adding information to your webpage

Note

Review the **Markdown Basic Syntax guide to help you format your webpage using Markdown and HTML. We also have a lesson in our Earth Data Science textbook that may be helpful.

Now you’re ready to start adding some more information to your webpage. Navigate back to your repository and open the index.md file that you just created. You will edit this page by clicking on the pencil icon on the right of the menu near the top of your repository page on GitHub. You will use Markdown and Hypertext Markup Language (HTML) to add text, links, images, and other content to your webpage. Markdown and HTML are both common markup langauges, and have wide application including formatting text, report writing, and website development.

Edit a file on GitHub

Here you should think about adding the following information to your webpage:

  • Your name (as a header) if you haven’t already
  • A bulleted list of links to your public contact information (email, GitHub account, LinkedIn account, social media accounts, etc.)
  • Your educational and professional background
  • A biographical paragraph about yourself
  • What you’re excited about learning about Earth Data Science
  • Questions that you’d like to answer using Earth Data Science

You should also plan to add a photo of yourself and/or where you live. We’ll go over how to add and customize images on your page in the next two lessons.

Warning

Always remember to commit changes so that your updated content gets added to your webpage.

STEP 2: Add images to your portfolio

Check out our demo video!

Follow along with our video demo here:

Images make your website easier to understand

The following code will display an image from the internet using Markdown:

![Mississippi Delta](https://deltax.jpl.nasa.gov/img/delta-google-earth.jpg)

Mississippi Delta

Image source: image of the Mississippi Delta from the Jet Propulsion Laboratory DeltaX project

Important

Always make sure you have permission to use images, and give credit to your image sources. Most images are fair to use for education (teaching, research, and study), as long as you give credit to your source. If you later on decide to use your portfolio to make money (for example, if you use it as marketing materials), then you should reconsider what images you are using.

Learn more about fair use from the CU Library Fair Use page.

Adding your own images

Including images from the web is the easiest way to add images to your site, but you will probably want to include your own images! There are three common ways that you can add images you have taken or created to your website:

  1. Uploading an image to your portfolio repository on GitHub
  2. Uploading an image elsewhere and then linking to it
  3. Generate an image with code and render it into your website

We’ll try out the first two options in this lesson. But first, you need to understand the difference between absolute and relative URLs on the web.

Upload an image to GitHub

STEP 1: Create an empty image directory on GitHub

It’s important to keep your files organized in a project like a website. Before uploading any images, you should make a place to put them. By convention, images in most websites are kept in the img directory, but you can name it whatever you want.

git, the system used by GitHub to keep track of changes to files, doesn’t keep a record of directories without any files in them, and as of now you can’t upload an image to a directory that doesn’t exist yet. This puts us in a bit of a pickle! Fortunately, there’s a common solution – we’ll create an empty text file named .keep in the new directory.

Speak Code – why .keep?

You could name your empty placeholder file anything you want. However, there are two good reasons to use .keep as your filename. First, files that start with a dot (.) are hidden in unix-based operating systems like linux and MacOS, which helps avoid clutter when you are looking at your files. Second, adhering to the convention means that anyone else looking at your repository will know what the .keep file is doing there.

To create a img/.keep file, go to the main page of your website repository on GitHub and click the Code tab. Then, find the + menu button on the upper right and select Add a file from the dropdown:

Click add a file

Type `img/.keep into the name field and then commit your changes:

Name the file img/.keep and commit

Click Commit

Click Commit again to confirm
Warning

When you type img/, GitHub will automatically make a folder, so only .keep will be visible in the text box.

STEP 2: Upload your image to the img directory

First, make sure that the name of your image file on your computer is descriptive and machine-readable (doesn’t contain any spaces or special characters other than _, -, or .). You won’t be able to rename your file once you upload it to GitHub.

You should now be in the img directory in your repository. If note, you can get there from the Code tab in your website repository, by clicking on the img directory in the files. From there, click the Add file menu in the upper right, but this time select Upload files:

Click on Add file, then Upload files

Drag your image file, or browse and select it.

Commit file upload

Finally, write a message and click Commit changes: Confirm your file upload commit by clicking commit

Other places to host images

GitHub has a couple of limitations when it comes to hosting images:

  1. The site will not allow you to upload files larger than 100MB
  2. If you make changes to an image file, GitHub will keep all the previous versions, which can make your repository unwieldy to download. If you are generating image files yourself and changing them frequently, consider hosting them somewhere else.

So, where can you host images that you have taken or generated? There are a few options:

  1. You can use the Free Image Hosting service to upload images without an account or giving up any information about yourself. Note that while you retain ownership of these images you are granting a license to Free Image Hosting to use them however they want.
  2. For a final version, you can use a research hosting service like figshare to upload images and get code to embed them in your website.
  3. If you want to use photos you have already uploaded to social media, you can usually get a direct link by right-clicking on the image and selecting Copy Image Link.
  4. You will likely find that most file storage services such as Google Drive and Dropbox don’t provide you with a direct link to images that you can use in a website. You can look for instructions on generating direct links for these files, but they are often unsupported and could change without warning.
  5. There’s another way of hosting on GitHub that doesn’t have the same drawbacks when it comes to large files. You can include files in a release, which creates a direct link to files, but does not attempt to track changes. To get started, follow the instructions from GitHub documentation. Note that once you have a release you can add additional files to it.
Warning

By uploading images to social media or other hosting services, you are sometimes giving up your rights to the image, or granting. Photo apps like Flickr are usually better bets, since they are built for photographers with copyright protection in mind. But be sure to read the fine print when uploading material that is sensitive to you personal or to your community – you can look for the term ownership rights in the Terms and Conditions of whatever sites you use.

STEP 3: Customize your website content

The building blocks of the web

Most web pages are built using three key technologies:

  • Hyper-Text Markup Language (HTML) includes and structures the content
  • Cascading Style Sheets (CSS) controls how the page looks
  • Javascript (JS) controls what the page does

When using GitHub Pages, you can rely on GitHub to translate Markdown to HTML before putting it on the web using a system called Jekyll. You can see the result by:

  1. Navigate to your portfolio page on the internet
  2. Right-click anywhere on the page
  3. Select an option like Inspect or Web Developer Tools, depending on your browser.

You should now see the source code for your webpage in a new panel. What do you notice about your content? How is it different from what you wrote?

Web developer tools
Tip

You can also control CSS and JS to a limited extent on GitHub Pages. However, we recommend sticking with the CSS and JS supplied by a Jekyll theme created by a designer. It’s hard to make a website that looks good from scratch. We’ll get into how to add a theme using Jekyll later on.

Use HTML to add features that aren’t available in Markdown

When creating your webpage, you might want to do a couple of things with your content that most types of Markdown can’t do, such as:

  • Specify the size of an image
  • Control whether links open up in a new tab
  • Embed videos and other web content
  • Change colors, fonts, or font sizes in one section of your page

HTML (Hyper-Text Markup Language), does have the ability to do all those things and more.

Make sure to format your HTML code so that it is readable

One great thing about Markdown is that it is both human-readable and machine-readable. It’s a little harder to tell what is going on with HTML, especially if it is formatted poorly. For example, take a look at some Markdown and its equivalent in HTML. Unlike Markdown, the computer doesn’t care how we use whitespace when formatting HTML. We can make HTML easier to read by adding whitespace and new lines:

1# A fabulous Earth Data Science Portfolio

2![Super-cool satellite imagery](/img/cool_satellite_image.jpeg)

Some text and [a link](https://www.my_link.org) and:

  * A
  * Bulleted
  * List
1
The will be a level 1 header because it begins with one #
2
This will be an image since it starts with a !
<h1>A fabulous Earth Data Science Portfolio</h1><img 
src="/img/cool_satellite_image.jpeg" alt-text="Super-cool satellite imagery">
<p>Some text and <a 
href="https://www.my_link.org">a link</a> 
and:</p><ul><li>A</li><li>Bulleted
</li><li>List</li></ul>
1<h1>A fabulous Earth Data Science Portfolio</h1>

2<!-- Comments help the reader understand your code -->
<img 
  src="/img/cool_satellite_image.jpeg" 
3  alt="Super-cool satellite imagery" />

<p>
  Some text and <a href="https://www.my_link.org">a link</a> 
  and:
</p>

<ul>
    <li>A</li>
    <li>Bulleted</li>
    <li>List</li>
</ul>
1
This is a level 1 header, since it is surrounded by h1 tags.
2
Comments won’t appear on your web page
3
The img tag will be an image.

HTML syntax for Markdown users

Every coding language has some special characters and structures, known as the syntax. When you render or run code, the syntax gets interpreted into some kind of behavior. For example, in Markdown, the syntax # gets interpreted as the start of a level 1 header.

HTML is less human-readable than Markdown. To use it effectively, you will need to understand some key vocabulary about the syntactic elements of HTML.

Tags

Speak Code

Remember that the < and > symbols are usually used to surround text you should replace with something applicable to you and your project. There’s a BIG exception when it comes to building websites – < and > are key special characters if you are using HTML, the markup language used on most websites. So, if the code sample is HTML, you should leave the angle brackets < and > in.

Notice that most elements are surrounded by tags enclosed in angle brackets (< and >). For example, when we include a header 1, we do that with the following code:

1<h1>
2  A fabulous Earth Data Science Portfolio
3</h1>
1
Start with the opening tag for h1 (header level 1), then
2
Place the text of the header in between the tags.
3
End with the closing tag, which match the opening tag plus a slash (/)
Tip

If there is no text that needs to go between two HTML tags, you don’t need a closing tag. Instead, you can end the opening tag with /> to indicate that there’s no content. For example, take another look at the image HTML code:

<img 
  src="/img/cool_satellite_image.jpeg" 
  alt="Super-cool satellite imagery" />

Parameters

In addition to marking the beginning and end of HTML elements, tags can contain addition information about how to display their contents. This extra information is known as parameters. For example, let’s revisit the code above for an HTML link, which contains the href parameter:

1<a href="https://www.my_link.org">
  a link
</a>
1
Parameters are included inside the opening tag. The parameter name (href) must be followed by and equals sign =, and the parameter value (https://www.my_link.org) must be surrounded by quotation marks.

Include HTML directly in Markdown

You can add HTML elements into your Markdown documents. There is no need when using GitHub Pages to write entire documents in HTML; you can directly substitute HTML elements for Markdown elements where needed. For example,

Adjust the size of images

Say you have written the following Markdown to display an image:

![Super-cute pika!](/img/pika.jpg)

Super-cute pika!

Image source: Wikipedia

Unfortunately, the image is taking up the entire width of the section. You can’t adjust the size with GitHub Markdown alone, but you can replace the image with HTML and control the width:

<img 
  src="/img/pika.jpg" 
  alt="Super-cute pika!" 
  width="25%">

Super-cute pika!

Warning

If you set both the width and the height of an image, your image will become distorted:

<img 
  src="/img/pika.jpg" 
  alt="Super-cute pika!" 
  height="100px" 
  width="400px">
Super-cute pika!

When setting image height and width, there are different units you can use:

Unit Meaning
px A pixel is the smallest item that can be displayed on your screen
em or rem These units are relative to your font size (e.g. the width of an m)
% A percentage of the element that contains the image

When using px, keep in mind that others may be viewing your webpage on different devices (e.g. phone vs. computer). px units are pegged to the resolution of the screen, so this can result in vastly different sizes on different devices. Furthermore, rem measurements will change if the viewer zooms in or out of the page in their browser, making them more accessible.

Tip

You can simulate what your webpage will look like on another device using the Web Developer Tools. Usually there’s a button that looks like a screen in the upper right.

Web developer tools with the device simulator highlighted

Embedding content from other webpages

Markdown is great for text and images, but what if you want to content that is hosted elsewhere, like a video? HTML lets you load content from other webpages (also known as embedding content) using an element called an iframe:

<iframe 
  width="467" height="831" 
  src="https://www.youtube.com/embed/Oly8f4h5C78" 
  title="Natural Habitat Shorts- Chipmunks have cheek pouches used to store food. 🐿🥜" 
  frameborder="0" 
  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" 
  allowfullscreen>
</iframe>

Usually the website that hosts your video will already have embed code prepared for you. For example, on YouTube you can find the embed code below the video:

Styling text

Style on a webpage refers to how the page looks. For example, you might want to change colors, fonts, or spacing on your page. Usually this would be done with CSS or with pre-styled theme elements. However, if you doing something small, you can use the style parameter in an HTML tag, as in the following examples:

Change the 
<span style="color: red; font-size: 2rem"> 
  color and font size
</span>.

Change the color and font size.

Tip

We are using the span tag here instead of the p (paragraph) tag, so that HTML will not put the text on a new line.

Add a border to an image:

Super-cool satellite imagery

<img 
  src="/img/cool_satellite_image.jpeg" 
  alt="Super-cool satellite imagery" 
  height="100rem"
  style="border: dashed 5px blue;">

STEP 4: Spruce up your website

Make attractive websites with themes

Website themes are a system for applying a particular design to your web content. They consist of acollection of website configuration files, content templates, and style files that control how a website looks, but can be filled in with any content. Themes are great because: * Your website will immediately look and function like the theme * Most themes allow you to change style elements (like colors and fonts), and store data (like your name and email address) in a central location. * Themed websites will most likely work on lots of different devices, like phones, tablets, and computers. You can double-check if your theme mentions being adaptive or responsive, bu most themes these days are. * Some themes support interactive components like photo carousels or lightboxes without needing to write a lot of code

Jekyll is a system for building websites from Markdown, HTML, and CSS. In fact, Jekyll is the system that GitHub Pages uses to deploy websites. This means that we can take advantage of free Jekyll themes to make any website look great.

Check out our themes demo video!

Jekyll plays well with GitHub Pages

Supported themes

We recommend starting out by using one of the GitHub Pages supported themes. Follow these instructions from GitHub.

Even if you don’t ultimately end up using one of these themes, you can make sure that everything is working with one of these themes.

Remote themes

GitHub Pages allows you to add any Jekyll theme available on GitHub to your site with a configuration file.

To do this you can: 1. Choose the Jekyll theme you want to use (here are some examples). Note that some themes work more seamlessly than others, so you may have to try more than one. 2. Preview the theme by clicking Live Demo on jekyllthemes.io, or searching the GitHub README for a preview link. 3. Follow the instructions from GitHub on how to apply the theme using a _config.yml file. 4. Go to the GitHub repository for the theme by clicking on the Get THEME on GitHub button on jekyllthemes.io. Follow any instructions about customizing things like your name or the title of your webpage.

So what is YAML?

The _config.yml file is written in YAML, a human-readable format for structured information (lists and key/value pairs). Learn more about YAML on their website

The _config.yml file that you created to add a theme can also sometimes be used to change the title of your website from the default (the name of your repository). Check out the README for your theme to see what parameters are available For example, and example _config.yml file for the minimal theme looks like:

title: J. Doe's Awesome Portfolio Website
description: Check out my projects!
logo: img/headshot.png
remote_theme: pages-themes/minimal@v0.2.0
Warning

You may need or want to add a _data/data.yml file or your own templates in _layouts in addition to the _config.yml file, depending on your theme. You will need to read the README for the theme you are using to see what you can customize. We recommend copying any example configuration files from the theme repository, and then modifying them to meet your needs.

References

Randall Munroe. 2013. “The Rise of Open Access.” Science 342 (6154): 58–59. https://www.science.org/doi/10.1126/science.342.6154.58.