Week 4. Advanced Building and Basic Computational Methods
Today, we will further customize our exhibits. In doing so, we will gain a better understanding of how Jekyll reads our CollectionBuilder templates.
Learning Objectives
- Understand how Jekyll generates your site.
- Understand how Jekyll uses the Liquid programming language.
- Create new pages using markdown, YAML, and liquid.
- Be able to use liquid includes to further customize your pages.
- Be able to customize your collection’s pages using the different config files.
More About Jekyll and Site Generation
Our short lecture explains some of the key aspects of navigating Jekyll and the CollectionBuilder framework in more detail. We’ll cover:
_config.yml: the file you used to structure your site.- Key-value pairs: Linked data items that establish constants (the key) and variables (the value). Collection Builder explains key-value pairs in their glossary entry about YAML
- YAML front matter: A small block of code that tells Jekyll more about how you want your page to look.
- Liquid: the programming language used by Jekyll.
Customizing Your CollectionBuilder Exhibit
We will address some of the key areas of CollectionBuilder site customization today. Our work today is in no way exhaustive. CollectionBuilder’s documentation explains even more ways you can further customize your site. The CB team is often exploring new ways to tweak the framework and sharing those developments via their documentation, discussion forum, and slack channels.
Edit Your About Page: Content and Exploring Liquid Includes
- Navigate to the
pagesfolder. - Open
about.md. - Generate your site using the terminal. A quick reminder:
- In the terminal, type the command
bundle exec jekyll sand press enter. This “jekyll serve” command will generate the site for you on a local server on your computer. - In the terminal you’ll see some text appear, including a URL that appears after the title “Server address:”
- Hold down
Ctrland click this link to open the site in your browser (or copy the URL and paste into a private window).
- In the terminal, type the command
- Notice how the html generated by Jekyll includes a lot more content than the code in your markdown. This is because Jekyll is reading the markdown written in the
Aboutpage and following the nesting of Liquid includes to pull from multiple places in your repository to generate this page.- If you scroll to line 27 of
about.md, you will see an include with the following path:cb/about_the_about.md. - Navigate to
cb/about_the_about.mdby going to the_includesfolder in your repository and then thecbfolder. There you will findabout_the_about.mdand a lot more markdown that resembles the html in your browser. - Now scroll down the
Aboutpage in your browser to see some includes that you may want to use in your exhibit.
- If you scroll to line 27 of
- Let’s remove some of the CB instructional content and add our own so visitors can learn more about our exhibit.
- Remove the two includes above
## About the Collection. - Remove all the content below the
## About the Collectionheader.
- Remove the two includes above
- Add markdown below
## About the Collectionto say something about your site. Some potential textual content includes:- Why your collection is interesting.
- Where the original contents are located.
- Future expansions of your exhibit and its relationship to the collection
- Who you and your team are.
- Add an image using an the
image.htmlinclude:- Identify an image you want to highlight on this page and record the objectid.
- Copy the include code block:
{% include feature/image.html objectid=yourid width="50" %}and paste it above the## About the Collectionheader. - edit the
objectidkey by changing the value to the right of the=sign. This should be an objectid from your metadata, such as latam001. (Tip: Remember what we discussed earlier about key-value pairs) - You can also change how much space the image takes up on your page by editing the value of the
widthkey.
- Add a card using the
card.htmlinclude:- Identify an image that will work well in a card and record the objectid.
- Copy the include code block:
{% include feature/card.html header="This is a Card" text="The card features an image from the collection as a cap" objectid="demo_001" width="25" centered=true %}and paste it in between paragraphs in yourAbout the Collectionsection. - Edit the following key-value pairs within the code block:
headertextobjectid
- We will keep the default values for the
widthandcenteredkeys, but you can change these to alter the location and appearance of the card.
- Save your
about.mdfile and refresh your browser to see how the page changed. If there is something appears incorrect or you don’t like how it looks, edit further. - When you are happy with the current iteration of your
Aboutpage, you can save, stage, commit, and push changes.
Create a New Page: Markdown and Your Directory Hierarchy
- Navigate to the
pagesdirectory. - Create a new file:
- Click the add new file icon in your VS Code explorer.
- Name the file and include the .md extension. Let’s name our file
history.md.
- Add the necessary YAML front matter variables so Jekyll knows how to build our page:
- You can do this manually by adding the
title,layout, andpermalinkkey-value pairs or copy the following code block:--- title: Collection History layout: about permalink: /history.html --- - Add content below the front matter that explains where your collection came from.
- You can do this manually by adding the
- Add your page to the
config.nav.csvfile. This adds your new page to the navigation bar so it is more easily discoverable.- Navigate to the
_datadirectory and open theconfig-nav.csvfile. - Create a new row in the csv by adding values that correspond with
display_textandstubkeys. - These values will correspond to your YAML front matter and your row will look like this:
Collection History,/history.html - Be sure to include the comma between the two values! Remember that the commas in a CSV represent a column divider.
- Navigate to the
- Save, stage, commit, and push changes.
Customize Display Options: Using the theme.yml File
- Navigate to the
_datafolder and open thetheme.ymlfile. - Scroll through and read the commented text to see what this file controls.
- You can use this file to alter every page the site builds.
- Some page structures may not need alteration at this time, but it is still a good idea to familiarize yourself with what you can change and how you may want to do so. To review how to change settings that we do not cover today, visit CB’s Theme Configuration Options documentation.
- We will edit our feature image and change the map view for anyone using geographic data.
Customizing the Feature Image
The feature image will be the banner image for your home page.
- Locate the
# HOME PAGEheader in thetheme.ymlfile. - Locate an image from your collection that is striking or representative of the collection. It is also a good idea to use an image that views well in a landscape setting. Record the objectid.
- Find the
featured-imagekey and change the image value to the objectid of your preferred image, such at latam001. (You can also use relative locations or a URL) - Save this change and refresh your browser to review its appearance.
- If you are unhappy with how CB is displaying a portion of the image, you can change the padding and the positioning:
home-title-y-paddingkey can be used to show more or less of the image. Use the range of2emto20emto adjust.home-banner-image-positionkey can be used to determine which portion of the image will be displayed. You can use the valuestop,center, orbottom.
- If you are unhappy with how CB is displaying a portion of the image, you can change the padding and the positioning:
Customizing the Map Page
The theme.yml file has default map page settings that center around Idaho, the location of the creators of CollectionBuilder. If you have added geographic data (latitude and longitude coordinates) to your metadata, you will want to adjust the map settings so that your objects are viewable when a visitor lands on your map page.
- Scroll down to the
# MAP PAGEheader in thetheme.ymlfile. - Find latitude and longitude coordinates that are roughly in the center of where your objects are located.
- For example, if your objects are located across South America, you may want to pick a point in southwest Brazil to better display your objects on the map page.
- Quick tip: To find map coordinates quickly, go to Google Maps and click your desired point. Then, right click your selected point on the map and a popup box will appear with your point coordinates and other options. Click the point coordinates to copy them to a clipboard.
- Change the values of the
latitudeandlongitudekeys by using the coordinates you copied from Google Maps.- Be sure to correctly separate latitude and longitude.
- Be sure to include the
-sign if it is in your coordinates.
- Change the
zoom-levelkey to a value that allows the map to display all your objects when a visitor first lands on your map page.zoom-levelcan be set at any whole number between [0-18]
- Save, stage, commit, and push changes.
More Configuration: Using the Many config.csv Files
Many of the CollectionBuilder pages are configured using “config” CSV files. You can find these in the _data folder. The different CSVs with the config- prefix will help you further customize your site. For example, you can use the config-map.csv file to change which information from your metadata appears in the pop-ups that appear on your map. Today, we are going to customize our navigation and the browser page using the config CSVs.
Changing the Configuration of the Navigation Bar
We are going to create a dropdown menu to demonstrate how you can configure the navigation bar.
- Navigate to the
_datafolder and open theconfig-nav.csvfile. - Note the three different columns of the csv:
display_name,stub,dropdown_parent.- We will alter and add values to create a dropdown menu.
- Create an “Explore” dropdown by adding a new row below
Home. The row should read as follows:Explore,.- The comma is necessary to signal the end of the
display_namevalue.
- The comma is necessary to signal the end of the
- Add the following rows to the
Exploredropdown:Browse,Subjects,Locations,Map,Timeline.- To do this add a
'(comma) after thestubvalue in each row and then addExplore - Do not use spaces!
- To do this add a
- Save the CSV and refresh your browser to see if the navigation updated.
Changing the Configuration of the Browse Page
Customizing your browse page allows you to better curate how your visitors explore your collection items. CB uses default metadata categories in their browse page that may not correspond with the metadata you included in your spreadsheet. The browse page displays specific metadata as a card for each object in your collection. This exercise will teach you how to change the display on each card and alter how one sorts the page.
- Navigate to the
_datafolder and open theconfig-browse.csvfile. - Note the different columns and review CB’s config-browse documentation to learn more about the categories.
- Review your metadata csv and identify a category you would like to add to an object card.
- Create a new row and add the field name. For example, if you want to include the object description, use the field name
description. Then add a,to complete the value. - Add a
display_namevalue. This will help the viewer understand what they are reading. If you are following our example, addDescription,. - Next, add another way for users to sort your items.
- Add a sort by
locationby changing the location row as follows:location,,true,,Location- The commas are required so that your sort by location value is in the correct column.
- This will create a new
sort bydrop down to the right of the search bar on theBrowsepage.
- Save your file and refresh your browser to make sure your new sort option displays correctly.
- Correct as needed, then save, stage, commit, and push changes.