Welcome to the workshop website for From Spreadsheet to Multilingual Website Using Oxygen XML Editor & Hugo Static Site Generator.
Here you will find all the information about the workshop and instructions to help you get started.
This workshop will use a subset of data and a simpler practice website from Recetas de las AmΓ©ricas, a bilingual website made with Hugo by Sarah Tew and Melissa Jerome.
My contact: sarahetew@ufl.edu
This tutorial is made for Windows and may need adjustments for macOS.
Tutorial GitHub: https://github.com/SarahTew/dlf-hugoΒ
Table of Contents
For Windows:
Go to the GitHub for Hugo Releases
Scroll to the Assets for the latest version.
Click "Show all 23 assets" at the bottom
Download the appropriate zip file: hugo_0.119.0_windows-amd64.zip (Note: This link will take you straight to the download)
Open the folder (it will be zipped, that's fine you can extract or not, it doesn't matter)
You should have 3 files in there: hugo.exe; LICENSE; and README.md
Create a "Hugo" folder (capitalization is important!!) on you C: drive
Inside the Hugo folder create a folder called "bin" (capitalization is important!!)
Put all three files: hugo.exe; LICENSE; and README.md inside the "bin" folder
Open the Command Prompt
In the Command Prompt type: set PATH=%PATH%;C:\Hugo\bin and hit enter
Test that Hugo was installed correctly : type hugo versionΒ into the Command Prompt and hit enter
If installed correctly you should see a long line of text that starts with hugo v0.119.0
If not installed you should see an error about hugo not being a recognized command
For Mac:
I recommend installing with a package manager like homebrew.
Image of Step 6: MakeΒ "Hugo" folder directly on your C: drive. Inside of the "Hugo", make another folder called "bin" and put the three files from the Hugo download inside "bin"
11. Correct hugo installation message for my (older) version. Yours likely says hugo v0.119.0
Request a free trial license
Follow Oxygen's Installation Instructions
Unzip and save the folder on your C: drive
Creating a local server will allow you test your site as you make changes.
Open the Command Prompt/Terminal
Β Navigate to the Hugo Test Site folder through the command prompt using: cd
Use cd.. to go up a directory
Use cd [name of folder] to go into a directory
Once you're in test-siteπ, type hugo server into the command prompt
If successful you will see a message that starts with Start building sites β¦ and then a table of what it builtΒ
If unsuccessful you will get an error that tells at which part of the building process it ran into a problem. You will need to fix this before it can build the site.
Open your internet browser and go to localhost:1313
If correct, you should see your website
If incorrect, you will not see anything on first load. If you make a so-called fatal error while developing your website, the localhost:1313 page will crash and display the same error message that's in the Command Prompt.
Check your website out! Check to make sure the recipes are there and the content is in the appropriate language
You must leave the local server up while you are working on your site.
If you close the Command Prompt window you started from, you will end the server and no longer see your site.Β When you open a new Command Prompt you will have to navigate back to the test-site directory
You can end the server in the Command Prompt with Ctrl+C and stay in the test-site directory
If you close your browser only, nothing will happen. Your server is still running.
Β Creating a local server with Hugo
test-siteπ Is where everything Hugo needs to build your site is stored.Β
source-dataπ is where you'll store the materials you need to process your original content into forms Hugo can use.
Hugo uses the other folders to create your website. It requires specific file structure and naming so do not rename or move folders.
We'll go more into what's in test-siteπ Β more in-depth later in the tutorial.
Find the trial_data spreadsheet in dlf-hugo π --> training materials π --> trial_data.xlsπ
Open it to take a look.
Features of the Spreadsheet
Saved as an xls (old version of Excel files)
Why: Easier import into Oxygen later
Column headings: No Spaces!
single-word headings and _ instead of space
Only one row of headings
Lists of things are in one cell together separated by semicolons
eg. chayote; cornstarch; sugar; egg; milk; salt; raisins; butter; cracker meal
eg. Split the chayotes lengthwise and boil.; When they are soft take out the pulp and mash well.; Beat the yolks with the sugar, add salt, and cornstarch, milk, mashed chayotes, butter and potatoes; Put on the fire and cook until thickened like a cream; Fill the rinds with the cream and sprinkle cinnamon on top.; Bake for ten minutes.
Only some fields have English and Spanish versions
Fields that stay the same across both langauges, like ID, the newspaper it's from, and the URL don't need translations
The Trial License Key
When you first open Oxygen, you may need to enter a license key.
If you are borrowing a laptop today, check the desktop for a text fileΒ with the license key
If you are using your own laptop, enter the key you requested from Oxygen if you have not already done so.
Making a new Oxygen Project
You will do all the work to develop your website in Oxygen. The Oxygen Project file helps you manage all your files.
Whatever you do in Oxygen will be reflected in your regular computer files and vice versa.
Click the "Project" tab at top left.
Click "New Project"
Β A file will show up. Navigate toΒ test-siteπ
Name your project
The name can be anything; I'm using UF_Hugo
You should now see the blue "Project" tab on the left with test-siteπ
Double click or use the small arrow on the left to open test-siteπ
You should see all the folders inside test-siteπ
UF_Hugo Project in Oxygen
You must import the spreadsheet in order to start working with it in Oxygen.
Click on the source-dataπ
You will see more folders and some .xsl files. Ignore for now.
Click the "File" tab in the upper left.
Click the file folder icon to open the file navigator
Β Go to training materials π --> trial_data.xlsπ
In the "Available Sheets" indow select "recetas"
Import criteria
Check the box that says "First row contains field names"
Uncheck the box that says "Import formatted data"
Use the horizontal scroll to go to the end and check for any blank columns
See the blank "Heading 16", "Heading 17", "Heading 18" columns.
Click the <> next to the heading name until it's an "x". This removes it from the import.
Β You can use this to delete any extra columns for your data that you don't want to import for use in your website.
Check the box that says "Open in Editor"
Don't check the box that says "Save in file" and click the small folder icon
Click Import
Oxygen should open trial_data.xmlπ in the viewer
Import Criteria box in Oxygen
Take a look at the XML and how it compares to the spreadsheet.
XML puts tags in your text content to structure the data.
Save the new xml in dlf-hugoπ --> test-siteπ --> source-dataπ
Name the file trial_data
Check that you can now see the trial_data.xmlπ in the project pane.
You will transform this xml into everything Hugo needs in order to build the website:
Markdown files
HTML partials files
You will transform them using XSLT and Oxygen's built-in tools for transforming XML into other formats.
In source-dataπ you have 4 .xsl files I have already written for you.
These files will be used to transform trial_data.xmlπ
Setting up a Transformation scenario
Right click on trial_data.xmlπ in the project pane
Hover over "Transfrom" in the menu
Select "Configure Transformation Scenario"
Click New
New XML transformation with XSLT
Β New Scenario window
Name the scenario table2md (I name my scenarios after the sheet I will use for them to help me keep them straight)
Check that the XML URL field says ${currentFileURL} (this is autopopulated)
For XSL URL click the small folder and select table2md.xslπ in source-dataπ
Output tab: If you want to save them to a separate folder for markdowns: make sure "Save as" is selected and ${pdu}/source-data/md/${cfn}.md is listed in the field.
Click "Apply Associated"
You should see new markdown files now in source-dataπ
Open one of the markdown files. How does to compare to the spreadsheet? To the XML?
New Transformation Scenario Configuration Screen for table2md
Creating the English markdown files
We're going to copy and edit table2md.xslπ it so it will create English markdown files.
Right click on table2md.xslπ in the Project pane. Copy and paste it in the same folder. Rename the copy table2md_en.
Open table2md_en.xslπ
Edits:
Line 7:Β add .en to the markdown file name : <xsl:result-document method="text" encoding="utf-8" href="{id}.en.md">
Add _en to the title, tags, ingredients, and course selections in blue
There are two of each in this XSL; try using Ctl + f to do a find and replace in Oxygen
Line 54: add .en to the html file in the readFile line: <xsl:text>{{< readFile file="./html/recipes/</xsl:text><xsl:value-of select="id"/><xsl:text>.en.html">}}</xsl:text>
Save table2md_en.xslπ
Create a new transformation scenario for your English sheet and run it.
Save as file path: change to Β ${pdu}/source-data/md/${cfn}.en.md
Check your new markdown files.
You can run multiple transformation scenarios at a time. Once you have both scenarios made you can select them both and generate the English and Spanish in one command.
Find and replace window in Oxygen
Creating the Spanish HTML partials
Oxygen got picky with me andΒ my html scenario didn't work as cleanly as the markdown one and I still haven't figured out why. When that happens, don't panic! Work around it!
Because of this issue, we need to split the XML into individual recipes.
Configure and then run a transformation scenario with split.xslπ to split the trial_data.xmlπ into separate xmls for each recipe.
Select all of the new xmls and then configure and run xml2html on them
Output tab: make sure the Save as button is checked and it has ${pdu}/source-data/html/${cfn}.html in the Save as field.
Your new htmls should populate in htmlπ inside source-dataπ
Creating the English HTML partials
We're going to copy and edit xml2html.xslπ to to create English html partials.
Create and open a copy named xml2html_enπ
Edits:
Line 22: Remove _en from ingredient_list_en
Line 23 remove _en from directions_en
Line 29: Add _en to field name <xsl:template match="ingredient_list_en">
Line 31: Change spelling to English Ingredients
Line 35: Add _en to field name <xsl:template match="directions_en">
Line 37: Change spelling to English Directions
Configure and run the xml2html_en scenario
Don't forget to change the Save as field
Check your files.
FYI: Oxygen will overwrite files with the same file name; if you didn't switch the Save as field you might get English files under the Spanish name and vice versa
Congratulations! You've transformed your spreadsheet into Markdown and HTML and are now ready for Hugo to build your site!
You need to move md and html files into Hugo's content folders to add them to the site.Β
Select and drag all the html files (English & Spanish) from source-dataπ-->htmlπ to contentπ-->htmlπ-->recipesπ
Select and drag all the md files from source-dataπ-->mdπ to contentπ-->recetasπ
Hugo requires a particular file organization to run correctly. Certain folders are mandatory to have, even if you do not use them.
The easiest way to start making a Hugo site is to adapt a very basic pre-existing hugo site.
You can use test-site as the basis of your first project
You can use a Hugo theme made by someone else. This will include a theme and an example site for you to adapt. A simpler theme is much easier to adapt.
You can also generate a blank site from the command prompt but you will also have to generate a new theme and it is more complicated.
Themes vs. site
Hugo has a hierarchical file structure so some folders and files override others.
The theme is a the basic skeleton of the website and gets supplement and/or overwritten by other folders in what I call your "site".
The test-site's theme, MyTheme is very basic.
Go to MyThemeπ --> layoutsπ
You'll see two folders, _defaultπ and partialsπ
_default layouts tell Hugo how to layout the main parts of your different webpages
partials tell Hugo how to layout the parts that appear on every page like navigation bars and footers and anything else you want appearing across the site in the same way.
Go to Β layoutsπ in your main site, outside of the theme.
You'll see another _defaultπ and partialsπ as well as recetasπ and shortcodesπ
Hugo ranks files in this layoutsπ higher than files with the same name in the MyThemeπ --> layoutsπ and will use these on the site
Why is this important: You can get a basic theme for your site then make all the changes you need in your site folders without having to worry about messing with the theme.
The recetasπ contains the layouts for the recipe pages.
Layouts vs. Content
Within your site, there is a Β layoutsπ and a contentπ
Layouts give Hugo instructions on where to find the parts it needs to assemble your website and instructions on how to arrange those parts on the website
Content are the parts Hugo will assemble.
Recipe text
Images & PDFs
Custom CSS
Markdown & HTML
Markdown files contain metadata about each page
HTML files are partial and provide some, but not all of the content that goes on each recipe page
Layouts tell Hugo how to assemble the HTML partials.
All of your content items must have their own markdown files.
Multilingual Websites
Hugo allows you to build a multilingual website without other software or plugins
You must structure your files correctly to do this
In the test-site, Spanish is the default language so the English files must have have an .en added. Spanish files can have nothing or .es
eg. Spanish markdown file: r01.md ; English markdown file: r01.en.md
eg. Spanish recipe page layout: single.es.html ; English recipe page layout: single.en.html
This is one of two ways to structure files for a multilingual website
See their Multilingual Mode Instructions on their website
You can also find good information about how to make a multilingual site from this blog
Hugo does NOT translate your content for you. You must provide your own translations.
The Config file
This is the most important file for your website
baseURL
This is the first line of your config file.Β
This tells Hugo how to write all the URLS it needs for your site and all the links in it
You must enter the final URL for your project here. If you enter it incorrectly, your site will look great on localhost:1313 but non-existant once you start hosting it on the web.
Theme
Make sure this matches the name of the theme you are using. If this is not set you will get an error when you try to build your site
Languages
Make sure to set a default language
Use the ISO 639-1 Code for the desired languages
List of language codes (use second column)
Taxonomies
Taxonomies are part of what makes Hugo really amazing and great for DH library projects
Taxonomies are essentially metadata fields that you tell Hugo to pay special attention to and keep track of for you. You can use them in your site to automatically create lists.
Because I have an "ingredientes" taxonomy listed in my config file and a default list template, it generates this page.Β
You can also use this capability to call lists and terms throughout your website, not just on a list page. An example of this is https://recetas.domains.uflib.ufl.edu/en/filtro/
The left side of this filter page was made by telling Hugo to go pull every term in the taxonomies for dietary restrictions, course, and ingredients.
Hugo knows which recipe contains each term because of the markdown files.
The right side of this page was made with a JSON file using Hugo's built-in data folder.
Edit your English Homepage
Go to layoutsπ-->index.en.htmlπ
Add some text to your English homepage and save.
Check your localhost:1313 to see your changes.
Edit the CSS
Go to contentπ-->cssπ --> styleπ
Change the color of the links in the navigation menu when you hover from pink toΒ blue.
Hint: find the section labeled "Hyperlinks"
Check your localhost1313 to see your changes.
Troubleshooting: If you are making changes to the CSS and nothing looks like it's changing in localhost:1313, test something you KNOW you can see and are doing correctly.Β
If you can see that change then you know that what you were trying to do before is wrong.Β
If you cannot see that change you know you should, it might be browser caching. In this case, clear your browser history of cached files and/or open localhost:1313 in a new browser.
Adding PDFs
Go to one of the recipes and click the pdf link.
You should get an error.
Add the pdf files into contentπ-->pdfπ
Check localhost:1313 and click the link now to see your changes.
Adding Recipe Images
Add the image files into the contentπ--> imagesπ--> recetasπ
Add these lines of code to your single.es.htmlπ and single.en.htmlπ templates
[START]
<div class="col-image">
{{$path := .Page.Params.jpg}}
<img class="recimg" style='height: 100%; width: 100%; object-fit: contain' alt="imagen de receta {{ .Params.title}} en el diario " src= {{ printf "../../images/recetas/%s" $path | urlize | absLangURL}}></img>
</div>
[END]
Change the words in bold for the English version: alt= "image of newspaper recipe {{ .Params.title}}"
Generate your site once you satisfied with your edits and ready to share it publicly.Β
One command will generate all the public files for your site. These are the static files you can take to wherever you are hosting your project.
Close the local server.
Ctrl+C will kee you in the same directory
You can close the command prompt but then you will have to navigate back to test-siteπ
Verify you are in test-siteπ
Type hugo and press enter.
You should see a similar table to when you made the local server with hugo serverΒ earlier.
If unsuccessful, there will be an error message specifying where and why Hugo got stuck and was unable to keep building.
Verify that a new public π is now in test-siteπ
Take a look at public π
How does it compare with the test-siteπ directories you worked with in Oxygen?
Successful generation of public files hugoΒ command
This tutorial isn't going to go into hosting.
Recetas is hosted by LibDomains.
Whether LibDomains or another hosting site, you will transfer the contents of public π on your machine into the public html folder of your website.Β
Once you transfer the files, the site is done and will not change unless and until you upload new public files. This makes a static site much cheaper and easier to maintain.
Control Panel File Manager screenhot. The files in the public folder generated by Hugo will be uploaded into public_html.