{"id":65800,"date":"2019-05-23T04:16:09","date_gmt":"2019-05-23T11:16:09","guid":{"rendered":"http:\/\/www.taterboy.com\/blog\/2019\/05\/switching-from-wordpress-to-hugo\/"},"modified":"2019-05-23T04:16:09","modified_gmt":"2019-05-23T11:16:09","slug":"switching-from-wordpress-to-hugo","status":"publish","type":"post","link":"https:\/\/www.taterboy.com\/blog\/2019\/05\/switching-from-wordpress-to-hugo\/","title":{"rendered":"Switching From WordPress To Hugo"},"content":{"rendered":"<link rel=\"canonical\" href=\"https:\/\/www.smashingmagazine.com\/2019\/05\/switch-wordpress-hugo\/\"><title>Switching From WordPress To Hugo<\/title><\/p>\n<article>\n<header>\n<h1>Switching From WordPress To Hugo<\/h1>\n<address>Christopher Kirk-Nielsen<\/address>\n<p>                  <time datetime=\"2019-05-22T14:30:00+02:00\">2019-05-22T14:30:00+02:00<\/time><time datetime=\"2019-05-23T11:05:56+00:00\">2019-05-23T11:05:56+00:00<\/time><\/header>\n<p>When WordPress 5 was released, I was excited about making use of the Gutenberg editor to create custom blocks, as posts on my personal blog had a couple of features I could turn into a block, making it easier to set up my content. It was definitely a cool thing to have, yet it still felt quite bloated.<\/p>\n<p>Around the same time, I started reading more and more about static site generators and the <a href=\"https:\/\/jamstack.org\/\">JAMstack<\/a> (<a href=\"https:\/\/gomakethings.com\/migrating-from-wordpress-to-hugo\/\">this article by Chris Ferdinandi convinced me<\/a>). With personal side projects, you can kind of dismiss a wide variety of issues, but as a professional, you have to ensure you output the best quality possible. Performance, security and accessibility become the first things to think about. You can definitely optimize WordPress to be pretty fast, but faster than a static site on a CDN that doesn\u2019t need to query the database nor generate your page every time? Not so easy.<\/p>\n<p>I thought that I could put this into practice with a personal project of mine to learn and then be able to use this for professional projects, and maybe some of you would like to know how, too. In this article, I will go over how I made the transition from WordPress to a specific static site generator named Hugo.<\/p>\n<div data-component=\"FeaturePanel\" data-audience=\"non-subscriber\" data-remove=\"true\"><\/div>\n<p>Hugo is built in <a href=\"https:\/\/golang.org\/\">Go<\/a>, which is a pretty fast and easy to use language once you get used to the syntax, which I will explain. It all compiles locally so you can preview your site right on your computer. The project will then be saved to a private repository. Additionally, I will walk you through how to host it on <a href=\"https:\/\/www.netlify.com\/\">Netlify<\/a>, and save your images on a Git LFS (Large File Storage). Finally, we\u2019ll have a look at how we can set up a content management system to add posts and images (similar to the WordPress backend) with Netlify CMS.<\/p>\n<p>Note that all of this is absolutely free, which is pretty amazing if you ask me (although you\u2019ll have to pay extra if you use up all your LFS storage or if your site traffic is intense). Also, I am writing this from a Bitbucket user point of view, running on a Mac. Some steps might be slightly different but you should be able to follow along, no matter what setup you use.<\/p>\n<p>You\u2019ll need to be somewhat comfortable with HTML, CSS, JS, Git and the command terminal. Having a few notions with templating languages such as Liquid could be useful as well, but we will review Hugo\u2019s templates to get you started. I will, nonetheless, provide as many details as possible!<\/p>\n<p>I know it sounds like a lot, and before I started looking into this, it was for me, too. I will try to make this transition as smooth as possible for you by breaking down the steps. It\u2019s not very difficult to find all the resources, but there was a bit of guesswork involved on my part, going from one documentation to the next.<\/p>\n<ol>\n<li><a href=\"https:\/\/www.smashingmagazine.com\/articles\/#exporting-content-from-wordpress\">Exporting The Content From WordPress<\/a><\/li>\n<li><a href=\"https:\/\/www.smashingmagazine.com\/articles\/#preparing-your-blog-design\">Preparing Your Blog Design<\/a><\/li>\n<li><a href=\"https:\/\/www.smashingmagazine.com\/articles\/#setting-up-a-new-repository\">Setting Up A New Repository<\/a><\/li>\n<li><a href=\"https:\/\/www.smashingmagazine.com\/articles\/#activating-git-lfs\">Activating Git LFS (Optional)<\/a><\/li>\n<li><a href=\"https:\/\/www.smashingmagazine.com\/articles\/#creating-site-netlify\">Creating The Site On Netlify<\/a><\/li>\n<li><a href=\"https:\/\/www.smashingmagazine.com\/articles\/#preparing-netlify-large-media\">Preparing For Netlify Large Media (Optional)<\/a><\/li>\n<li><a href=\"https:\/\/www.smashingmagazine.com\/articles\/#setting-up-hugo-computer\">Setting Up Hugo On Your Computer<\/a><\/li>\n<li><a href=\"https:\/\/www.smashingmagazine.com\/articles\/#creating-your-custom-theme\">Creating Your Custom Theme<\/a><\/li>\n<li><a href=\"https:\/\/www.smashingmagazine.com\/articles\/#notes-hugo-syntax\">Notes On The Hugo Syntax<\/a><\/li>\n<li><a href=\"https:\/\/www.smashingmagazine.com\/articles\/#content-and-data\">Content And Data<\/a><\/li>\n<li><a href=\"https:\/\/www.smashingmagazine.com\/articles\/#deploying-on-netlify\">Deploying On Netlify<\/a><\/li>\n<li><a href=\"https:\/\/www.smashingmagazine.com\/articles\/#setting-up-custom-domain\">Setting Up A Custom Domain<\/a><\/li>\n<li><a href=\"https:\/\/www.smashingmagazine.com\/articles\/#editing-content-netlify-cms\">Editing Content On Netlify CMS<\/a><\/li>\n<\/ol>\n<p><strong>Note<\/strong>: <em>If you have trouble with some of these, please let me know in the comments and I\u2019ll try to help, but please note this is destined to be applied to a simple, static blog that doesn\u2019t have a dozen widgets or comments (you can set that up later), and not a company site or personal portfolio. You undoubtedly could, though, but for the sake of simplicity, I\u2019ll stick to a simple, static blog.<\/em><\/p>\n<h4>Prerequisites<\/h4>\n<p>Before we do anything, let\u2019s create a project folder where everything from our tools to our local repository is going to reside. I\u2019ll call it \u201cWP2Hugo\u201d (feel free to call it anything you want).<\/p>\n<p>This tutorial will make use of a few command line tools such as npm and Git. If you don\u2019t have them already, install those on your machine:<\/p>\n<ul>\n<li><a href=\"https:\/\/git-scm.com\/book\/en\/v2\/Getting-Started-Installing-Git\">Install Git<\/a><\/li>\n<li><a href=\"https:\/\/nodejs.org\/en\/\">Install Node.js and npm<\/a> (Node.js includes npm)<\/li>\n<li><a href=\"https:\/\/brew.sh\/\">Install Homebrew<\/a> (recommended for macOS\/Linux users)<\/li>\n<\/ul>\n<p>With these installed, let\u2019s get started!<\/p>\n<h3>1. Exporting The Content From WordPress<\/h3>\n<p>First off, we\u2019ll need to export your content from WordPress: posts, pages, and uploads. There are a <a href=\"https:\/\/gohugo.io\/tools\/migrations\/#wordpress\">few tools available that Hugo mentions<\/a> but personally, only one of them worked: <a href=\"https:\/\/github.com\/palaniraja\/blog2md\">blog2md<\/a>. This one works by running a JavaScript file with Node.js in your command terminal. It takes the XML files exported by WordPress, and outputs Markdown files with the right structure, converting your HTML to Markdown and adding what is called the <a href=\"https:\/\/gohugo.io\/content-management\/front-matter\/\">Front Matter<\/a>, which is a way to format metadata at the start of each file.<\/p>\n<p>Go to your WordPress admin, and open the Tools menu, Export submenu. You can export what you want from there. I\u2019ll refer to the exported file as <em>YOUR-WP-EXPORT.xml<\/em>.<\/p>\n<figure><a href=\"https:\/\/i0.wp.com\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/6fb27068-47f3-4cc9-8aa2-53ae91a033e6\/1-wordpress-export.png?ssl=1\"><\/p>\n<p>    <img data-recalc-dims=\"1\" decoding=\"async\" srcset=\"http:\/\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/05\/1-wordpress-export.png 400w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_800\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/6fb27068-47f3-4cc9-8aa2-53ae91a033e6\/1-wordpress-export.png 800w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1200\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/6fb27068-47f3-4cc9-8aa2-53ae91a033e6\/1-wordpress-export.png 1200w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1600\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/6fb27068-47f3-4cc9-8aa2-53ae91a033e6\/1-wordpress-export.png 1600w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_2000\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/6fb27068-47f3-4cc9-8aa2-53ae91a033e6\/1-wordpress-export.png 2000w\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/05\/1-wordpress-export.png?w=900\" sizes=\"100vw\" alt=\"The WordPress back-end interface with arrows indicating each step to reach the export feature.\"><\/a><figcaption>\n      WordPress export tool (<a href=\"https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/6fb27068-47f3-4cc9-8aa2-53ae91a033e6\/1-wordpress-export.png\">Large preview<\/a>)<br \/>\n    <\/figcaption><\/figure>\n<p>You can select exactly what data you want to export from your WordPress blog.<\/p>\n<p>Inside our WP2Hugo folder, I recommend creating a new folder named <code>blog2md<\/code> in which you\u2019ll place the files from the blog2md tool, as well as your XML export from WordPress (<em>YOUR-WP-EXPORT.xml<\/em>). Also, create a new folder in there called <code>out<\/code> where your Markdown posts will go. Then, open up your command terminal, and navigate with the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Cd_(command)\"><code>cd<\/code> command<\/a> to your newly created \u201cblog2md\u201d folder (or type <code>cd<\/code> with a space and drag the folder into the terminal).<\/p>\n<p>You can now run the following commands to get your posts:<\/p>\n<pre><code>npm install\nnode index.js w YOUR-WP-EXPORT.xml out\n<\/code><\/pre>\n<p>Look into the <code>\/WP2Hugo\/blog2md\/out<\/code> directory to check whether all of your posts (and potential pages) are there. If so, you might notice there\u2019s something about comments in the documentation: I had a comment-free blog so I didn\u2019t need them to be carried through but Hugo does offer <a href=\"https:\/\/gohugo.io\/content-management\/comments\/\">several options for comments<\/a>. If you had any comments on WordPress, you can export them for later re-implementation with a specialized service like Disqus.<\/p>\n<p>If you\u2019re familiar enough with JS, you can tweak the <em>index.js<\/em> file to change how your post files will come out by editing the <code>wordpressImport<\/code> function. You may want to capture the featured image, remove the permalink, change the date format, or set the type (if you have posts and pages). You\u2019ll have to adapt it to your needs, but know that the loop (<code>posts.forEach(function(post){ ... })<\/code>) runs through all the posts from the export, so you can check for the XML content of each post in that loop and customize your Front Matter.<\/p>\n<p>Additionally, if you need to update URLs contained in your posts (in my case, I wanted to make image links relative instead of absolute) or the date formatting, this is a good time to do so, but don\u2019t lose sleep over it. Many text editors offer bulk editing so you can plug in a regular expression and make the changes you want across your files. Also, you can run the <code>blog2md<\/code> script as many times as needed, as it will overwrite any previously existing files in the output folder.<\/p>\n<p>Once you have your exported Markdown files, your content is ready. The next step is to get your WordPress theme ready to work in Hugo.<\/p>\n<h3>2. Preparing Your Blog Design<\/h3>\n<p>My blog had a typical layout with a header, a navigation bar, content and sidebar, and a footer \u2014 quite simple to set up. Instead of copying pieces of my WordPress theme, I rebuilt it all from scratch to ensure there was no superfluous styles or useless markup. This is a good time to implement new CSS techniques (<em>pssst\u2026 Grid is pretty awesome!<\/em>) and set up a more consistent naming strategy (something like <a href=\"https:\/\/cssguidelin.es\/\">CSS Wizardry\u2019s guidelines<\/a>). You can do what you want, but remember we\u2019re trying to optimize our blog, so it\u2019s good to review what you had and decide if it\u2019s still worth keeping.<\/p>\n<p>Start by breaking down your blog into parts so you can clearly see what goes where. This will help you structure your markup and your styles. By the way, Hugo has the built-in ability to compile Sass to CSS, so feel free to break up those styles into smaller files as much as you want!<\/p>\n<figure><a href=\"https:\/\/i0.wp.com\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/4ec1c640-c05f-49c5-8524-0b16af5bee0f\/2-design-layout.png?ssl=1\"><\/p>\n<p>    <img data-recalc-dims=\"1\" decoding=\"async\" srcset=\"http:\/\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/05\/2-design-layout.png 400w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_800\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/4ec1c640-c05f-49c5-8524-0b16af5bee0f\/2-design-layout.png 800w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1200\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/4ec1c640-c05f-49c5-8524-0b16af5bee0f\/2-design-layout.png 1200w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1600\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/4ec1c640-c05f-49c5-8524-0b16af5bee0f\/2-design-layout.png 1600w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_2000\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/4ec1c640-c05f-49c5-8524-0b16af5bee0f\/2-design-layout.png 2000w\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/05\/2-design-layout.png?w=900\" sizes=\"100vw\" alt=\"A blog layout with a banner up top, with a menu below it. The main area has a large section for content and a smaller side area for secondary content. At the bottom is a footer with a copyright note and links to the author\u2019s Twitter page and their email.\"><\/a><figcaption>\n       A very simple blog layout. (<a href=\"https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/4ec1c640-c05f-49c5-8524-0b16af5bee0f\/2-design-layout.png\">Large preview<\/a>)<br \/>\n    <\/figcaption><\/figure>\n<p>When I say simple, I mean really simple.<\/p>\n<p>Alternatively, you can completely bypass this step for now, and style your blog as you go when your Hugo site is set up. I had the basic markup in place and preferred an iterative approach to styles. It\u2019s also a good way to see what works and what doesn\u2019t.<\/p>\n<div><\/div>\n<h3>3. Setting Up A New Repository<\/h3>\n<p>Now that that is out of the way, we need to set up a repository. I\u2019m going to assume you will want to create a new repository for this, which is going to be a great opportunity to use Git LFS (Large File System). The reason I advise to do this now is that implementing Git LFS when you already have hundreds of images is not as smooth. I\u2019ve done it, but it was a headache you\u2019re likely to want to avoid. This will also provide other benefits down the road with Netlify.<\/p>\n<p>While I\u2019ll be doing all this via Bitbucket and their proprietary Git GUI, Sourcetree, you can absolutely do this with GitHub and GitLab and their own desktop tools. You can also do it directly in the command terminal, but I like to automate and simplify the process as much as I can, reducing the risk of making silly mistakes.<\/p>\n<p>When you\u2019ve created your new repository on the Git platform of your choice, create an empty folder inside your local project folder (WP2Hugo), e.g. <code>hugorepo<\/code>, then open up your command terminal or Git GUI tool and initialize your local Git repository; then, link it to the remote repository (you can usually find the exact command to use on the newly created remote repository).<\/p>\n<p>I\u2019d recommend creating a <code>dev<\/code> (or <code>stage<\/code>) branch so that your main branch is strictly used for production deployments. It\u2019ll also limit new builds to be generated only when you\u2019re done with a potential series of changes. Creating a branch can be done locally or on your repository\u2019s remote webpage.<\/p>\n<figure><a href=\"https:\/\/i0.wp.com\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/6cc91652-5dea-4f47-b5dc-84e203cc6152\/3-create-branch.png?ssl=1\"><\/p>\n<p>    <img data-recalc-dims=\"1\" decoding=\"async\" srcset=\"http:\/\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/05\/3-create-branch.png 400w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_800\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/6cc91652-5dea-4f47-b5dc-84e203cc6152\/3-create-branch.png 800w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1200\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/6cc91652-5dea-4f47-b5dc-84e203cc6152\/3-create-branch.png 1200w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1600\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/6cc91652-5dea-4f47-b5dc-84e203cc6152\/3-create-branch.png 1600w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_2000\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/6cc91652-5dea-4f47-b5dc-84e203cc6152\/3-create-branch.png 2000w\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/05\/3-create-branch.png?w=900\" sizes=\"100vw\" alt=\"A guide to the various steps to get to the 'New branch' form on repositories. GitHub requires the user to click the active branch and type a new name in the input field. GitLab requires the user to click a 'plus' menu that reveals a dropdown menu with a 'New branch' link to a page with the form. Bitbucket requires the user to click the 'plus' in the general menu to slide out options and to click the 'Create a branch' link to access a new page with the form.\"><\/a><figcaption>\n      How to create a new branch on GitHub, GitLab and Bitbucket. (<a href=\"https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/6cc91652-5dea-4f47-b5dc-84e203cc6152\/3-create-branch.png\">Large preview<\/a>)<br \/>\n    <\/figcaption><\/figure>\n<p>GitHub makes it easy to create a branch by clicking the branch switcher and typing a new name. On GitLab, you need to open the \u201cPlus\u201d dropdown to access the option. Bitbucket requires you to open the \u201cPlus\u201d menu on the left to open the slide-out menu and click \u201cCreate a branch\u201d in the \u201cGet to work\u201d section.<\/p>\n<h3>4. Activating Git LFS (Optional)<\/h3>\n<p>Git Large File System is a Git feature that allows you to save large files in a more efficient way, such as Photoshop documents, ZIP archives and, in our case, images. Since images can need versioning but are not exactly code, it makes sense to store them differently from regular text files. The way it works is by storing the image on a remote server, and the file in your repository will be a text file which contains a pointer to that remote resource.<\/p>\n<p>Alas, it\u2019s not an option you just click to enable. You must set up your repository to activate LFS and this requires some work locally. With Git installed, you need to <a href=\"https:\/\/git-lfs.github.com\/\">install a Git-LFS extension<\/a>:<\/p>\n<pre><code>git lfs install\n<\/code><\/pre>\n<p>If, like me, that command didn\u2019t work for you, try the Homebrew alternative (for macOS or Linux):<\/p>\n<pre><code>brew install git-lfs\n<\/code><\/pre>\n<p>Once that\u2019s done, you\u2019ll have to specify which files to track in your repository. I will host all of the images I uploaded in WordPress\u2019s <code>\/upload<\/code> folder in an identically-named folder on my Hugo setup, except that this folder will be inside a <code>\/static<\/code> folder (which will resolves to the root once compiled). Decide on your folder structure, and track your files inside:<\/p>\n<pre><code>git lfs track \"static\/uploads\/*\"\n<\/code><\/pre>\n<p>This will track any file inside the <code>\/static\/uploads<\/code> folder. You can also use the following:<\/p>\n<pre><code>git lfs track \"*.jpg\"\n<\/code><\/pre>\n<p>This will track any and all JPG files in your repository. You can mix and match to only track JPGs in a certain folder, for example.<\/p>\n<p>With that in place, you can commit your LFS configuration files to your repository and push that to your remote repository. The next time you locally commit a file that matches the LFS tracking configuration, it will be \u201cconverted\u201d to an LFS resource. If working on a development branch, merge this commit into your main branch.<\/p>\n<p>Let\u2019s now take a look at Netlify.<\/p>\n<div><\/div>\n<h3>5. Creating The Site On Netlify<\/h3>\n<p>At this point, your repository is set up, so you can go ahead and <a href=\"https:\/\/app.netlify.com\/signup\">create an account on Netlify<\/a>. You can even log in with your GitHub, GitLab or Bitbucket account if you like. Once on the dashboard, click the \u201cNew site from Git\u201d button in the top right-hand corner, and create your new Netlify site.<\/p>\n<p><strong>Note<\/strong>: <em>You can leave all the options at their default values for now.<\/em><\/p>\n<figure><a href=\"https:\/\/i0.wp.com\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/f8a947db-a9db-4cf7-8761-9c5ef44d7d92\/4-netlify-create.png?ssl=1\"><\/p>\n<p>    <img data-recalc-dims=\"1\" decoding=\"async\" srcset=\"http:\/\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/05\/4-netlify-create.png 400w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_800\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/f8a947db-a9db-4cf7-8761-9c5ef44d7d92\/4-netlify-create.png 800w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1200\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/f8a947db-a9db-4cf7-8761-9c5ef44d7d92\/4-netlify-create.png 1200w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1600\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/f8a947db-a9db-4cf7-8761-9c5ef44d7d92\/4-netlify-create.png 1600w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_2000\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/f8a947db-a9db-4cf7-8761-9c5ef44d7d92\/4-netlify-create.png 2000w\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/05\/4-netlify-create.png?w=900\" sizes=\"100vw\" alt=\"The form displayed on Netlify when a user creates a new website, with build options left to their default, empty values.\"><\/a><figcaption>\n      Netlify\u2019s new site creation page. (<a href=\"https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/f8a947db-a9db-4cf7-8761-9c5ef44d7d92\/4-netlify-create.png\">Large preview<\/a>)<br \/>\n    <\/figcaption><\/figure>\n<p>Select your Git provider: this will open a pop-up window to authenticate you. When that is done, the window will close and you\u2019ll see a list of repositories on that Git provider you have access to. Select your freshly created repo and continue. You\u2019ll be asked a few things, most of which you can just leave by default as all the options are editable later on.<\/p>\n<p>For now, in the Site Settings, click \u201cChange site name\u201d and name your site anything you want \u2014 I\u2019ll go with <code>chris-smashing-hugo-blog<\/code>. We will now be able to access the site via <code>chris-smashing-hugo-blog.netlify.com<\/code>: a beautiful 404 page!<\/p>\n<h3>6. Preparing For Netlify Large Media (Optional)<\/h3>\n<p>If you set up Git LFS and plan on using Netlify, you\u2019ll want to follow these steps. It\u2019s a bit more convoluted but definitely worth it: it\u2019ll enable you to set query strings on image URLs that will be automatically transformed.<\/p>\n<p>Let\u2019s say you have a link to <em>portrait.jpg<\/em> which is an image that\u2019s 900\u00d71600 pixels. With Netlify Large Media, you can call the file <em>portrait.jpg?nf_resize=fit&#038;w=420<\/em>, which will proportionally scale it. If you define both <code>w<\/code> and <code>h<\/code>, and set <code>nf_resize=smartcrop<\/code>, it\u2019ll resize by cropping to focus on the point of interest of the image (as determined by a fancy algorithm, a.k.a. <em>robot brain magic!<\/em>). I find this to be a great way to have thumbnails like the ones WordPress generates, without needing several files for an image on my repository.<\/p>\n<p>If this sounds appealing to you, let\u2019s set it up!<\/p>\n<p>The first step is installing Netlify\u2019s command-line interface (CLI) via npm:<\/p>\n<pre><code>npm install netlify-cli -g\n<\/code><\/pre>\n<p>If it worked, running the command <code>netlify<\/code> should result in info about the tool.<\/p>\n<p>You\u2019ll then need to make sure you are in your local repository folder (that I named \u201chugorepo\u201d earlier), and execute:<\/p>\n<pre><code>netlify login\n<\/code><\/pre>\n<p>Authorize the token. Next, we\u2019ll have to install the Netlify Large Media plugin. Run:<\/p>\n<pre><code>netlify plugins:install netlify-lm-plugin\nnetlify lm:install\n<\/code><\/pre>\n<p>There should be a command line shown at the end of the resulting message that you must copy (which should look like <code>\/Users\/YOURNAME\/.netlify\/helper\/path.bash.inc<\/code> on Mac) \u2014 run it. Note that Keychain might ask you for your machine\u2019s administrator password on macOS.<\/p>\n<p>The next step is to link Netlify:<\/p>\n<pre><code>netlify link\n<\/code><\/pre>\n<p>You can provide your site name here (I provided the <code>chris-smashing-hugo-blog<\/code> name I gave it earlier). With this in place, you just need to set up the Large Media feature by executing the following:<\/p>\n<pre><code>netlify lm:setup\n<\/code><\/pre>\n<p>Commit these new changes to your local repository, and push them to the remote development branch. I had a few errors with Sourcetree and Keychain along the lines of <code>git \"credential-netlify\" is not a git command<\/code>. If that\u2019s your case, try to manually push with these commands:<\/p>\n<pre><code>git add -A\ngit commit -m \"Set up Netlify Large media\"\ngit push\n<\/code><\/pre>\n<p>If that didn\u2019t work, you might need to <a href=\"https:\/\/github.com\/netlify\/netlify-credential-helper\">install Netlify credential Helper<\/a>. Here\u2019s how to do it with Homebrew:<\/p>\n<pre><code>brew tap netlify\/git-credential-netlify\nbrew install git-credential-netlify\n<\/code><\/pre>\n<p>Try pushing your commit through now (either with your GUI or command terminal): it should work!<\/p>\n<p><strong>Note<\/strong>: <em>If you change your Netlify password, run<\/em> <code>netlify logout<\/code> <em>and<\/em> <code>netlify login<\/code> <em>again.<\/em><\/p>\n<p>You might ask: \u201cAll this, and we still haven\u2019t even initialized our Hugo build?\u201d Yes, I know, it took a while but all the preparations for the transition are done. We can now get our Hugo blog set up!<\/p>\n<h3>7. Setting Up Hugo On Your Computer<\/h3>\n<p>You\u2019ll first need to <a href=\"https:\/\/gohugo.io\/getting-started\/installing\/\">install Hugo on your computer<\/a> with any of the provided options. I\u2019ll be using Homebrew but Windows users can use Scoop or Chocolatey, or download a package directly.<\/p>\n<pre><code>brew install hugo\n<\/code><\/pre>\n<p>You\u2019ll then need to create a new Hugo site but it won\u2019t like setting it up in a non-empty folder. First option: you can create it in a new folder and move its contents to the local repository folder:<\/p>\n<pre><code>hugo new site your_temporary_folder\n<\/code><\/pre>\n<p>Second option: you can force it to install in your local repository with a flag, just make sure you\u2019re running that in the right folder:<\/p>\n<pre><code>hugo new site . --force\n<\/code><\/pre>\n<p>You now have a Hugo site, which you can spin up with this command:<\/p>\n<pre><code>hugo server\n<\/code><\/pre>\n<p>You\u2019ll get a local preview on <code>localhost<\/code>. Sadly, you have no content and no theme of your own. Not to worry, we\u2019ll get that set up really soon!<\/p>\n<p>Let\u2019s first have a look at the configuration file (<em>config.toml<\/em> in my case): let\u2019s set up the blog\u2019s name and base URL (this must match the URL on your Netlify dashboard):<\/p>\n<pre><code>title = \"Chris\u2019 Smashing Hugo Blog\"\nbaseURL = \"https:\/\/chris-smashing-hugo-blog.netlify.com\"\n<\/code><\/pre>\n<p>This link will be overwritten while you develop locally, so you shouldn\u2019t run into 404 errors.<\/p>\n<p>Let\u2019s give Hugo our exported articles in Markdown format. They should be sitting in the <code>\/WP2Hugo\/blog2md\/out<\/code> folder from the first step. In the Hugo folder (a.k.a. the local repository directory), access the <code>content<\/code> folder and create a subfolder named <code>posts<\/code>. Place your Markdown files in there, and then let\u2019s get a theme set up.<\/p>\n<h3>8. Creating Your Custom Theme<\/h3>\n<p>For this step, I recommend downloading the <a href=\"https:\/\/themes.gohugo.io\/saito-boilerplate\/\">Saito boilerplate<\/a>, which is a theme with all the partials you\u2019ll need to get started (and no styles) \u2014 a very useful starting point. You could, of course, look at this <a href=\"https:\/\/themes.gohugo.io\/\">collection of ready-made themes for Hugo<\/a> if you want to skip over this part of the process. It\u2019s all up to you!<\/p>\n<p>From the local repository folder, clone the theme into <code>themes\/saito<\/code>:<\/p>\n<div>\n<pre><code>git submodule add https:\/\/github.com\/hakuoku\/saito-boilerplate.git themes\/saito  \n<\/code><\/pre>\n<\/div>\n<p>You can rename this folder to anything you want, such as <code>cool-theme<\/code>. You\u2019ll have to tell your Hugo configuration which theme you want to use by editing your <em>config.toml\/yaml\/json<\/em> file. Edit the theme value to <code>saito<\/code>, or <code>cool-theme<\/code>, or whatever your theme\u2019s folder name is. Your preview should now show your blog\u2019s title along with a copyright line. It\u2019s a start, right?<\/p>\n<p>Open the theme\u2019s <em>layout\/partials\/home.html<\/em> file and edit it to display your content, limiting to the five first items which are of type <code>posts<\/code> (inside the <code>content\/posts\/<\/code> folder), with <a href=\"https:\/\/gohugo.io\/functions\/range\/\"><code>range<\/code><\/a>, <a href=\"https:\/\/gohugo.io\/functions\/first\/\"><code>first<\/code><\/a> and <a href=\"https:\/\/gohugo.io\/functions\/where\/\"><code>where<\/code><\/a>:<\/p>\n<pre><code><div class=\"container\">\n{{ range first 5 (where .Paginator.Pages \"Type\" \"posts\") }}\n    <article class=\"post post--{{ .Params.class }}\">\n        <h2 class=\"post__title\">{{ .Title }}<\/h2>\n        <section class=\"post__content\">\n            {{ .Content }}\n        <\/section>\n    <\/article>\n{{ end }}\n<\/div>\n<\/code><\/pre>\n<p>Your content is now visible, in the most basic of ways. It\u2019s time to make it yours \u2014 let\u2019s dive in!<\/p>\n<h4>Templating With Hugo<\/h4>\n<p>You can first <a href=\"https:\/\/gohugo.io\/templates\/introduction\/\">read the Introduction to Hugo templating<\/a> if you like, but I\u2019ll try to go over a few essentials that will help you understand the basics.<\/p>\n<p>All operations in Hugo are defined inside delimiters: double curly braces (e.g. <code>{{ .Title }}<\/code>), which should feel familiar if you\u2019ve done a bit of templating before. If you haven\u2019t, think of it as a way to execute operations or inject values at a specific point in your markup. For blocks, they end with the <code>{{ end }}<\/code> tag, for all operations aside from shortcodes.<\/p>\n<p>Themes have a <code>layout<\/code> folder which contains the pieces of the layout. The <code>_default<\/code> folder will be Hugo\u2019s starting point, <em>baseof.html<\/em> being (<em>you guessed it!<\/em>) the base of your layout. It will call each component, called \u201cpartials\u201d (more on this on Hugo\u2019s documentation about <a href=\"https:\/\/gohugo.io\/templates\/partials\/\">Partial Template<\/a>), similar to how you would use <code>include<\/code> in PHP, which you may have already seen in your WordPress theme. Partials can call other partials \u2014 just don\u2019t make it an infinite loop.<\/p>\n<p>You can call a partial with <code>{{ partial \"file.html\" . }}<\/code> syntax. The <code>partial<\/code> section is pretty straightforward, but the two other ones might need explaining. You might expect to have to write <em>partials\/file.html<\/em> but since all partials are to be in the partials\u201d folder, Hugo can find that folder just fine. Of course, you can create subfolders inside the \u201cpartials\u201d folder if you need more organization.<\/p>\n<p>You may have noticed a stray dot: this is the context you\u2019re passing to your partial. If you had a menu partial, and a list of links and labels, you could pass that list into the partial so that it could only access to that list, and nothing else. I\u2019ll talk more about this elusive dot in the <a href=\"https:\/\/www.smashingmagazine.com\/articles\/#notes-hugo-syntax\">next section<\/a>.<\/p>\n<p>Your <em>baseof.html<\/em> file is a shell that calls all the various partials needed to render your blog layout. It should have minimal HTML and lots of partials:<\/p>\n<div>\n<pre><code><!DOCTYPE html>\n<html lang=\"{{ .Site.LanguageCode }}\">\n    <head>\n        <title>{{ block \"title\" . }}{{ .Site.Title }}{{ end }}<\/title>\n        {{ partial \"head.html\" . }}\n    <\/head>\n    <body>\n        {{ partial \"header.html\" . }}\n        {{ partial \"nav.html\" . }}\n\n        <main>\n            {{ block \"main\" . }}{{ end }}\n        <\/main>\n\n        <aside>\n            {{ partial \"sidebar.html\" . }}\n        <\/aside>\n\n        {{ partial \"footer.html\" . }}\n    <\/body>\n<\/html>\n<\/code><\/pre>\n<\/div>\n<p>The <code>{{ block \"main\" . }}{{ end }}<\/code> line is different because it is a block that is defined with a template based on the content of the current page (homepage, single post page, etc.) with <code>{{ define \"main\" }}<\/code>.<\/p>\n<h4>Stylesheets<\/h4>\n<p>In your theme, create a folder named <code>assets<\/code> in which we will place a <code>css<\/code> folder. It will contain our SCSS files, or a trusty ol\u2019 CSS file. Now, there should be a <em>css.html<\/em> file in the <code>partials<\/code> folder (which gets called by <em>head.html<\/em>). To convert Sass\/SCSS to CSS, and minify the stylesheet, we would use this series of functions (using the <a href=\"https:\/\/gohugo.io\/hugo-pipes\/introduction\/\">Hugo Pipes syntax<\/a> instead of wrapping the functions around each other):<\/p>\n<div>\n<pre><code>{{ $style := resources.Get \"css\/style.scss\" | toCSS | minify | fingerprint }}\n<link rel=\"stylesheet\" href=\"%7B%7B%20%24style.Permalink%20%7D%7D\" type=\"text\/css\"><\/code><\/pre>\n<\/div>\n<p>As a bonus \u2014 since I struggled to find a straight answer \u2014 if you want to use Autoprefixer, Hugo also implements PostCSS. You can add an extra pipe function between <code>toCSS<\/code> and <code>minify<\/code> on the first line, like so:<\/p>\n<div>\n<pre><code>{{ $style := resources.Get \"css\/style.scss\" | toCSS | postCSS | minify | fingerprint }}\n<\/code><\/pre>\n<\/div>\n<p>Create a \u201cpostcss.config.js\u201d file at the root of your Hugo blog, and pass in the options, such as:<\/p>\n<pre><code>module.exports = {\n    plugins: {\n        autoprefixer: {\n            browsers: [\n                \"> 1%\",\n                \"last 2 versions\"\n            ]\n        }\n    },\n}\n<\/code><\/pre>\n<p>And presto! From Sass to prefixed, minified CSS. The \u201cfingerprint\u201d pipe function is to make sure the filename is unique, like <em>style.c66e6096bdc14c2d3a737cff95b85ad89c99b9d1.min.css<\/em>. If you change the stylesheet, the fingerprint changes, so the filename is different, and thus, you get an <a href=\"https:\/\/csswizardry.com\/2019\/03\/cache-control-for-civilians\/#cache-busting\">effective cache busting solution<\/a>.<\/p>\n<h3>9. Notes On The Hugo Syntax<\/h3>\n<p>I want to make sure you understand \u201cthe Dot\u201d, which is how Hugo scopes variables (or in my own words, provides a contextual reference) that you will be using in your templates.<\/p>\n<h4>The Dot And Scoping<\/h4>\n<p>The Dot is like a top-level variable that you can use in any template or shortcode, but its value is scoped to its context. The Dot\u2019s value in a top-level template like <em>baseof.html<\/em> is different from the value inside loop blocks or <code>with<\/code> blocks.<\/p>\n<p>Let\u2019s say this is in our template in our <em>head.html<\/em> partial:<\/p>\n<pre><code>{{ with .Site.Title }}<title>{{ . }}<\/title>{{ end }}\n<\/code><\/pre>\n<p>Even though we are running this in the main scope, the Dot\u2019s value changes based on context, which is <code>.Site.Title<\/code> in this case. So, to print the value, you only need to write <code>.<\/code> instead of re-typing the variable name again. This confused me at first but you get used to it really quick, and it helps with reducing redundancy since you only name the variable once. If something doesn\u2019t work, it\u2019s usually because you\u2019re trying to call a top-level variable inside a scoped block.<\/p>\n<p>So how do you use the top-level scope inside a scoped block? Well, let\u2019s say you want to check for one value but use another. You can use <code>$<\/code> which will always be the top-level scope:<\/p>\n<div>\n<pre><code>{{ with .Site.Params.InfoEnglish }}{{ $.Site.Params.DescriptionEnglish }}{{ end }}\n<\/code><\/pre>\n<\/div>\n<p>Inside our condition, the scope is <code>.Site.Params.InfoEnglish<\/code> but we can still access values outside of it with <code>$<\/code>, where intuitively using <code>.Site.Params.DescriptionEnglish<\/code> would not work because it would attempt to resolve to <code>.Site.Params.InfoEnglish.Site.Params.DescriptionEnglish<\/code>, throwing an error.<\/p>\n<h4>Custom Variables<\/h4>\n<p>You can assign variables by using the following syntax:<\/p>\n<pre><code>{{ $customvar := \"custom value\" }}\n<\/code><\/pre>\n<p>The variable name must start with <code>$<\/code> and the assignment operator must be <code>:=<\/code> if it\u2019s the first time it\u2019s being assigned, <code>=<\/code> otherwise like so:<\/p>\n<pre><code>{{ $customvar = \"updated value\" }}\n<\/code><\/pre>\n<p>The problem you might run into is that this won\u2019t transpire out of the scope, which brings me to my next point.<\/p>\n<h4>Scratch<\/h4>\n<p>The <a href=\"https:\/\/gohugo.io\/functions\/scratch\">Scratch functionality<\/a> allows you to assign values that are available in all contexts. Say you have a list of movies in a <em>movies.json<\/em> file:<\/p>\n<pre><code>[\n    {\n        \"name\": \"The Room\",\n        \"rating\": 4\n    },\n    {\n        \"name\": \"Back to the Future\",\n        \"rating\": 10\n    },\n    {\n        \"name\": \"The Artist\",\n        \"rating\": 7\n    }\n]\n<\/code><\/pre>\n<p>Now, you want to iterate over the file\u2019s contents and store your favorite one to use later. This is where Scratch comes into play:<\/p>\n<div>\n<pre><code>{{ .Scratch.Set \"favouriteMovie\" \"None\" }}{{ \/* Optional, just to get you to see the difference syntax based on the scope *\/ }}\n\n{{ range .Site.Data.movies }}\n        {{ if ge .rating 10 }}\n            {{ \/* We must use .Scratch prefixed with a $, because the scope is .Site.Data.movies, at the current index of the loop *\/ }}\n            {{ $.Scratch.Set \"favouriteMovie\" .name }}\n        {{ end }}\n{{ end }}\n[...]\nMy favourite movie is {{ .Scratch.Get \"favouriteMovie\" }}\n<!-- Expected output => My favourite movie is Back to the Future -->\n<\/code><\/pre>\n<\/div>\n<p>With Scratch, we can extract a value from inside the loop and use it anywhere. As your theme gets more and more complex, you will probably find yourself reaching for Scratch.<\/p>\n<p><strong>Note<\/strong>: <em>This is merely an example as this loop can be optimized to output this result without Scratch, but this should give you a better understanding of how it works.<\/em><\/p>\n<h4>Conditionals<\/h4>\n<p>The syntax for conditionals is a bit different from what you\u2019d expect \u2014 from a JavaScript or PHP perspective. There are, in essence, functions which take two arguments (parenthesis optional if you call the values directly):<\/p>\n<pre><code>{{ if eq .Site.LanguageCode \"en-us\" }}Welcome!{{ end }}\n<\/code><\/pre>\n<p>There are several of these functions:<\/p>\n<ul>\n<li><a href=\"https:\/\/gohugo.io\/functions\/eq\/\"><code>eq<\/code><\/a> checks for equality<\/li>\n<li><a href=\"https:\/\/gohugo.io\/functions\/ne\/\"><code>ne<\/code><\/a> checks for inequality<\/li>\n<li><a href=\"https:\/\/gohugo.io\/functions\/gt\/\"><code>gt<\/code><\/a> check for greater than<\/li>\n<li><a href=\"https:\/\/gohugo.io\/functions\/ge\/\"><code>ge<\/code><\/a> check for great than or equal to<\/li>\n<li><a href=\"https:\/\/gohugo.io\/functions\/lt\/\"><code>lt<\/code><\/a> checks for lesser than<\/li>\n<li><a href=\"https:\/\/gohugo.io\/functions\/le\/\"><code>le<\/code><\/a> checks for lesser than or equal to<\/li>\n<\/ul>\n<p><strong>Note<\/strong>: <em>You can learn all about the functions Hugo offers in the <a href=\"https:\/\/gohugo.io\/functions\">Hugo Functions Quick Reference<\/a>.<\/em><\/p>\n<h4>Whitespace<\/h4>\n<p>If you\u2019re as picky about the output as I am, you might notice some undesired blank lines. This is because Hugo will parse your markup as is, leaving blank lines around conditionals that were not met, for example.<\/p>\n<p>Let\u2019s say we have this hypothetical partial:<\/p>\n<pre><code>{{ if eq .Site.LanguageCode \"en-us\" }}\n<p>Welcome to my blog!<\/p>\n{{ end }}\n<img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/05\/portrait.jpg?w=900\" alt=\"Blog Author\">\n<\/code><\/pre>\n<p>If the site\u2019s language code is not <code>en-us<\/code>, this will be the HTML output (note the three empty lines before the image tag):<\/p>\n<pre><code><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/05\/portrait.jpg?w=900\" alt=\"Blog Author\">\n<\/code><\/pre>\n<p><a href=\"https:\/\/gohugo.io\/templates\/introduction\/#whitespace\">Hugo provides a syntax<\/a> to address this with a hyphen beside the curly braces on the inside of the delimiter. <code>{{-<\/code> will trim the whitespace before the braces, and <code>-}}<\/code> will trim the whitespace after the braces. You can use either or both at the same time, but just make sure there is a space between the hyphen and the operation inside of the delimiter.<\/p>\n<p>As such, if your template contains the following:<\/p>\n<pre><code>{{- if eq .Site.LanguageCode \"en-us\" -}}\n<p>Welcome to my blog!<\/p>\n{{- end -}}\n<img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/05\/portrait.jpg?w=900\" alt=\"Blog Author\">\n<\/code><\/pre>\n<p>\u2026then the markup will result in this (with no empty lines):<\/p>\n<pre><code><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/05\/portrait.jpg?w=900\" alt=\"Blog Author\">\n<\/code><\/pre>\n<p>This can be helpful for other situations like elements with <code>display: inline-block<\/code> that should not have whitespace between them. Conversely, if you want to make sure each element is on its own line in the markup (e.g. in a <code>{{ range }}<\/code> loop), you\u2019ll have to carefully place your hyphens to avoid \u201cgreedy\u201d whitespace trimming.<\/p>\n<p>The example above would output the following if the site\u2019s language code matches \u201c<code>en-us<\/code>\u201d (no more line breaks between the <code>p<\/code> and <code>img<\/code> tags):<\/p>\n<div>\n<pre><code><p>Welcome to my blog!<\/p><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/05\/portrait.jpg?w=900\" alt=\"Blog Author\">\n<\/code><\/pre>\n<\/div>\n<h3>10. Content And Data<\/h3>\n<p>Your content is stored as Markdown files, but you can use HTML, too. Hugo will render it properly when building your site.<\/p>\n<p>Your homepage will call the <code>_default\/list.html<\/code> layout, which might look like this:<\/p>\n<pre><code>{{ define \"main\" }}\n    {{ partial \"list.html\" . }}\n{{ end }}\n<\/code><\/pre>\n<p>The main block calls the <code>list.html<\/code> partial with the context of <code>.<\/code>, a.k.a. the top level. The <code>list.html<\/code> partial may look like this:<\/p>\n<div>\n<pre><code>{{ define \"main\" }}\n<ol class=\"articles\">\n    {{ range .Paginator.Pages }}\n        <li>\n            <article>\n                <a href=\"{{ .URL }}\">\n                    <h2>{{ .Title }}<\/h2>\n                    <img decoding=\"async\" src=\"{{ .Params.featuredimage }}\" alt=\"\">\n                    <time datetime=\"{{ .Date.Format \"2006-01-02\" }}\">\n                        {{ .Date.Format \"January 2 2006\" }}\n                    <\/time>\n                <\/a>\n            <\/article>\n        <\/li>\n    {{ end }}\n<\/ol>\n{{ partial \"pagination.html\" . }}\n{{ end }}\n<\/code><\/pre>\n<\/div>\n<p>Now we have a basic list of our articles, which you can style as you wish! The number of articles per page is defined in the configuration file, with <code>paginate = 5<\/code> (in TOML).<\/p>\n<p>You might be utterly confused as I was by the <a href=\"https:\/\/gohugo.io\/functions\/format\/\">date formatting in Hugo<\/a>. Each time the unit is mapped out to a number (first month, second day, third hour, etc.) made a lot more sense to me once I saw the visual explanation below that the Go language documentation provides \u2014 which is kind of weird, but kind of smart, too!<\/p>\n<pre><code> Jan 2 15:04:05 2006 MST\n=> 1 2  3  4  5    6  -7\n<\/code><\/pre>\n<p>Now all that\u2019s left to do is to display your post on a single page. You can edit the <code>post.html<\/code> partial to customize your article\u2019s layout:<\/p>\n<div>\n<pre><code><article>\n    <header>\n        <h1>{{ .Title }}<\/h1>\n        <p>\n            Posted on <time datetime=\"{{ .Date.Format \"2006-01-02\" }}\">{{ .Date.Format \"2006. 1. 2\" }}<\/time>\n        <\/p>\n    <\/header>\n    <section>\n        {{ .Content }}\n    <\/section>\n<\/article>\n<\/code><\/pre>\n<\/div>\n<p>And that\u2019s how you display your content!<\/p>\n<p>If you\u2019d like to customize the URL, update your configuration file by adding a <code>[permalinks]<\/code> option (TOML), which in this case will make the URLs look like <code>my-blog.com\/post-slug\/<\/code>:<\/p>\n<pre><code>[permalinks]\n    posts = \":filename\/\"\n<\/code><\/pre>\n<p>If you want to generate an RSS feed of your content (because RSS is awesome), add the following in your site configuration file (Saito\u2019s default template will display the appropriate tags in <em>head.html<\/em> if these options are detected):<\/p>\n<pre><code>rssLimit = 10\n[outputFormats]\n    [outputFormats.RSS]\n        mediatype = \"application\/rss\"\n        baseName = \"feed\"\n<\/code><\/pre>\n<p>But what if you had some sort of content outside of a post? That\u2019s where <a href=\"https:\/\/gohugo.io\/templates\/data-templates\/\">data templates<\/a> comes in: you can create JSON files and extract their data to create your menu or an element in your sidebar. YAML and TOML are also options but less readable with complex data (e.g. nested objects). You could, of course, set this in your site\u2019s configuration file, but it is \u2014 to me \u2014 a bit less easy to navigate and less forgiving.<\/p>\n<p>Let\u2019s create a list of \u201ccool sites\u201d that you may want to show in your sidebar \u2014 with a link and a label for each site as an array in JSON:<\/p>\n<div>\n<pre><code>{\n    \"coolsites\": [\n        { \"link\": \"https:\/\/smashingmagazine.com\", \"label\": \"Smashing Magazine\" },\n        { \"link\": \"http:\/\/gohugo.io\/\", \"label\": \"Hugo\" },\n        { \"link\": \"https:\/\/netlify.com\", \"label\": \"Netlify\" }\n    ]\n}\n<\/code><\/pre>\n<\/div>\n<p>You can save this file in your repository root, or your theme root, inside a <code>data<\/code> folder, such as <code>\/data\/coolsites.json<\/code>. Then, in your <code>sidebar.html<\/code> partial, you can iterate over it with <code>range<\/code> using <code>.Site.Data.coolsites<\/code>:<\/p>\n<pre><code><h3>Cool Sites:<\/h3>\n<ul>\n{{ range .Site.Data.coolsites.coolsites }}\n    <li><a href=\"{{ .link }}\">{{ .label }}<\/a><\/li>\n{{ end }}\n<\/ul>\n<\/code><\/pre>\n<p>This is very useful for any kind of custom data you want to iterate over. I used it to create a Google Fonts list for my theme, which categories the posts can be in, authors (with bio, avatar and homepage link), which menus to show and in which order. You can really do a lot with this, and it is pretty straightforward.<\/p>\n<p>A final thought on data and such: anything you put in your Hugo <code>\/static<\/code> folder will be available on the root (<code>\/<\/code>) on the live build. The same goes for the theme folder.<\/p>\n<h3>11. Deploying On Netlify<\/h3>\n<p>So you\u2019re done, or maybe you just want to see what kind of magic Netlify operates? Sounds good to me, as long as your local Hugo server doesn\u2019t return an error.<\/p>\n<p>Commit your changes and push them to your remote development branch (<code>dev<\/code>). Head over to Netlify next, and access your site\u2019s settings. You will see an option for \u201cBuild &#038; deploy\u201d. We\u2019re going to need to change a couple of things here.<\/p>\n<ol>\n<li>First, in the \u201cBuild settings\u201d section, make sure \u201cBuild command\u201d is set to <code>hugo<\/code> and that \u201cPublish directory\u201d is set to <code>public<\/code> (the default that is recommended you keep on your Hugo config file);<\/li>\n<li>Next, in the \u201cDeploy contexts\u201d section, set \u201cProduction branch\u201d to your main branch in your repository. I also suggest your \u201cBranch deploys\u201d to be set to \u201cDeploy only the production branch\u201d;<\/li>\n<li>Finally, in the \u201cEnvironment variables\u201d section, edit the variables and click \u201cNew variable\u201d. We\u2019re going to set the Hugo environment to 0.53 with the following pair: set key to <code>HUGO_VERSION<\/code> and value to <code>0.53<\/code>.<\/li>\n<\/ol>\n<p>Now head on over to your remote repository and merge your development branch into your main branch: this will be the hook that will deploy your updated blog (this can be customized but the default is reasonable to me).<\/p>\n<p>Back to your Netlify dashboard, your site\u2019s \u201cProduction deploys\u201d should have some new activity. If everything went right, this should process and resolve to a \u201cPublished\u201d label. Clicking the deploy item will open an overview with a log of the operations. Up top, you will see \u201cPreview deploy\u201d. Go on, click it \u2014 you deserve it. It\u2019s alive!<\/p>\n<h3>12. Setting Up A Custom Domain<\/h3>\n<p>Having the URL as <code>my-super-site.netlify.com<\/code> isn\u2019t to your taste, and you already own <code>my-super-site.com<\/code>? I get it. Let\u2019s change that!<\/p>\n<p>Head over to your domain registrar and go to your domain\u2019s DNS settings. Here, you\u2019ll have to create a new entry: you can either set an ALIAS\/CNAME record that points to <code>my-super-site.netlify.com<\/code>, or set an A record that points your domain to Netlify\u2019s load balancer, which is <code>104.198.14.52<\/code> at the time of writing.<\/p>\n<p>You can find the latest information on Netlify\u2019s documentation on <a href=\"https:\/\/www.netlify.com\/docs\/custom-domains\/\">custom domains<\/a>. The load balancer IP will be in the <a href=\"https:\/\/www.netlify.com\/docs\/custom-domains\/#dns-configuration\">DNS settings<\/a> section, under \u201c<a href=\"https:\/\/www.netlify.com\/docs\/custom-domains\/#manual-dns-configuration-for-root-and-www-custom-domains\">Manual DNS configuration for root and www custom domains<\/a>\u201d.<\/p>\n<p>When that\u2019s done, head over to your site\u2019s dashboard on Netlify and click \u201cDomain settings\u201d, where you\u2019ll see \u201cAdd custom domain\u201d. Enter your domain name to verify it.<\/p>\n<p>You can also manage your domains via <a href=\"https:\/\/app.netlify.com\/\">your dashboard<\/a> in the Domains tab. The interface feels less confusing on this page, but maybe it will help make more sense of your DNS settings as it did for me.<\/p>\n<p><strong>Note<\/strong>: <em>Netlify can also handle everything for you if you want to buy a domain through them. It\u2019s easier but it\u2019s an extra cost.<\/em><\/p>\n<p>After you\u2019ve set up your custom domain, in \u201cDomain settings\u201d, scroll down to the \u201cHTTPS\u201d section and enable the SSL\/TLS certificate. It might take a few minutes but it will grant you a free certificate: your domain now runs on HTTPS.<\/p>\n<h3>13. Editing Content On Netlify CMS<\/h3>\n<p>If you want to edit your articles, upload images and change your blog settings like you\u2019d do on WordPress\u2019 back-end interface, you can use Netlify CMS which has a pretty good <a href=\"https:\/\/www.netlifycms.org\/docs\/add-to-your-site\/\">tutorial<\/a> available. It\u2019s a single file that will handle everything for you (and it is generator-agnostic: it will work with Jekyll, Eleventy, and so on).<\/p>\n<p>You just need to upload two files in a folder:<\/p>\n<ul>\n<li>the CMS (a single HTML file);<\/li>\n<li>a config file (a YAML file).<\/li>\n<\/ul>\n<p>The latter will hold all the settings of your particular site.<\/p>\n<p>Go to your Hugo root\u2019s <code>\/static<\/code> folder and create a new folder which you will access via <code>my-super-site.com\/FOLDER_NAME<\/code> (I will call mine <code>admin<\/code>). Inside this <code>admin<\/code> folder, create an <em>index.html<\/em> file by copying the markup provided by Netlify CMS:<\/p>\n<div>\n<pre><code><!doctype html>\n<html>\n<head>\n    <meta charset=\"utf-8\" \/>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" \/>\n    <title>Content Manager<\/title>\n<\/head>\n<body>\n<!-- Include the script that builds the page and powers Netlify CMS -->\n    <script src=\"https:\/\/unpkg.com\/netlify-cms@^2.0.0\/dist\/netlify-cms.js\"><\/script>\n<\/body>\n<\/html>\n<\/code><\/pre>\n<\/div>\n<p>The other file you\u2019ll need to create is the configuration file: <em>config.yml<\/em>. It will allow you to define your site\u2019s settings (name, URL, etc.) so that you can set up what your posts\u2019 front matter should contain, as well as how your data files (if any) should be editable. It\u2019s a bit more complex to set up, but that doesn\u2019t mean it isn\u2019t easy.<\/p>\n<p>If you\u2019re using GitHub or GitLab, start your <em>config.yml file<\/em> with:<\/p>\n<pre><code>backend:\n    name: git-gateway\n    branch: dev # Branch to update (optional; defaults to master)\n<\/code><\/pre>\n<p>If you\u2019re using Bitbucket, it\u2019s a bit different:<\/p>\n<pre><code>backend:\n    name: bitbucket\n    repo: your-username\/your-hugorepo\n    branch: dev # Branch to update (optional; defaults to master)\n<\/code><\/pre>\n<p>Then, for our uploads, we\u2019ll have to tell the CMS where to store them:<\/p>\n<div>\n<pre><code>media_folder: \"static\/images\/uploads\" # Media files will be stored in the repo under static\/images\/uploads\npublic_folder: \"\/images\/uploads\" # The src attribute for uploaded media will begin with \/images\/uploads\n<\/code><\/pre>\n<\/div>\n<p>When you create a new post, the CMS will generate the slug for the filename which you can customize with three options:<\/p>\n<div>\n<pre><code>slug:\n    encoding: \"ascii\" # You can also use \"unicode\" for non-Latin\n    clean_accents: true # Removes diacritics from characters like \u00e9 or \u00e5\n    sanitize_replacement: \"-\" # Replace unsafe characters with this string\n<\/code><\/pre>\n<\/div>\n<p>Finally, you\u2019ll need to define how the data in your posts is structured. I will also define how the data file <em>coolsites<\/em> is structured \u2014 just in case I want to add another site to the list. These are set with the <code>collections<\/code> object which will definitely be the most verbose one, along with a nice handful of options you can read more about <a href=\"https:\/\/www.netlifycms.org\/docs\/configuration-options\/#collections\">here<\/a>.<\/p>\n<div>\n<pre><code>collections:\n    - name: \"articles\" # Used in routes, e.g., \/admin\/collections\/blog\n        label: \"Articles\" # Used in the Netlify CMS user interface\n        folder: \"content\/posts\" # The path to the folder where the posts are stored, usually content\/posts for Hugo\n        create: true # Allow users to create new documents in this collection\n        slug: \"{{slug}}\" # Filename template, e.g., post-title.md\n        fields: # The fields for each document, usually in front matter\n            - {label: \"Title\", name: \"title\", widget: \"string\", required: true}\n            - {label: \"Draft\", name: \"draft\", widget: \"boolean\", default: true }\n            - {label: \"Type\", name: \"type\", widget: \"hidden\", default: \"post\" }\n            - {label: \"Publish Date\", name: \"date\", widget: \"date\", format: \"YYYY-MM-DD\"}\n            - {label: \"Featured Image\", name: \"featuredimage\", widget: \"image\"}\n            - {label: \"Author\", name: \"author\", widget: \"string\"}\n            - {label: \"Body\", name: \"body\", widget: \"markdown\"}\n    - name: 'coolsites'\n            label: 'Cool Sites'\n            file: 'data\/coolsites.json'\n            description: 'Website to check out'\n            fields:\n                - name: coolsites\n                    label: Sites\n                    label_singular: 'Site'\n                    widget: list\n                    fields:\n                        - { label: 'Site URL', name: 'link', widget: 'string', hint: 'https:\/\/\u2026' }\n                        - { label: 'Site Name', name: 'label', widget: 'string' }\n<\/code><\/pre>\n<\/div>\n<p><strong>Note<\/strong>: <em>You can read more about how to configure individual fields in the <a href=\"https:\/\/www.netlifycms.org\/docs\/widgets\">Netlify CMS Widgets documentation<\/a> which goes over each type of widget and how to use them \u2014 especially useful for date formats.<\/em><\/p>\n<h4>Authentication<\/h4>\n<p>The last thing we need to do is to ensure only authorized users can access the backend! Using your Git provider\u2019s authentication is an easy way to go about this.<\/p>\n<p>Head over to your Netlify site and click the \u201cSettings\u201d tab. Then go to \u201cAccess control\u201d which is the last link in the menu on the left side. Here, you can <a href=\"https:\/\/www.netlify.com\/docs\/authentication-providers\/\">configure OAuth<\/a> to run via GitHub, GitLab or Bitbucket by providing a key and a secret value defined for your user account (not in the repository). You\u2019ll want to use the same Git provider as the one your repo is saved on.<\/p>\n<h5>GitHub<\/h5>\n<p>Go to your \u201cSettings\u201d page on GitHub (click your avatar to reveal the menu), and access \u201cDeveloper Settings\u201d. Click \u201cRegister a new application\u201d and provide the required values:<\/p>\n<ul>\n<li>a name, such as \u201cNetlify CMS for my super blog\u201d;<\/li>\n<li>a homepage URL, the link to your Netlify site;<\/li>\n<li>a description, if you feel like it;<\/li>\n<li>the application callback URL, which must be \u201c<code>https:\/\/api.netlify.com\/auth\/done<\/code>\u201d.<\/li>\n<\/ul>\n<p>Save, and you\u2019ll see your Client ID and Client Secret. Provide them to Netlify\u2019s Access Control.<\/p>\n<h5>GitLab<\/h5>\n<p>Click your avatar to access the Settings page, and click \u201cApplications\u201d in the \u201cUser Settings\u201d menu on the left. You\u2019ll see a form to add a new application. Provide the following information:<\/p>\n<ul>\n<li>a name, such as \u201cNetlify CMS for my super blog\u201d;<\/li>\n<li>a redirect URI, which must be \u201c<code>https:\/\/api.netlify.com\/auth\/done<\/code>\u201d;<\/li>\n<li>the scopes that should be checked are:\n<ul>\n<li><code>api<\/code><\/li>\n<li><code>read_user<\/code><\/li>\n<li><code>read_repository<\/code><\/li>\n<li><code>write_repository<\/code><\/li>\n<li><code>read_registry<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Saving your application will give you your Application ID and Secret, that you can now enter on Netlify\u2019s Access Control.<\/p>\n<h5>Bitbucket<\/h5>\n<p>Head over to your user account settings (click your avatar, then \u201cBitbucket settings\u201d). Under \u201cAccess Management\u201d, click \u201cOAth\u201d. In the \u201cOAuth consumers\u201d section, click \u201cAdd consumer\u201d. You can leave most things at their default values except for these:<\/p>\n<ul>\n<li>a name, such as \u201cNetlify CMS for my super blog\u201d;<\/li>\n<li>a callback URL, which must be \u201c<code>https:\/\/api.netlify.com\/auth\/done<\/code>\u201d;<\/li>\n<li>the permissions that should be checked are:\n<ul>\n<li>Account: Email, Read, Write<\/li>\n<li>Repositories: Read, Write, Admin<\/li>\n<li>Pull Requests: Read, Write<\/li>\n<li>Webhooks: Read and write<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>After saving, you can access your key and secret, which you can then provide back on Netlify\u2019s Access Control.<\/p>\n<p>After providing the tokens, go to Netlify, and find the Site Settings. Head to \u201cIdentity\u201d and enable the feature. You can now add an External Provider: select your Git provider and click on \u201cEnable\u201d.<\/p>\n<p>In case you need additional details, Netlify CMS has an <a href=\"https:\/\/www.netlifycms.org\/docs\/add-to-your-site\/#authentication\">authentication guide<\/a> you can read.<\/p>\n<p>You can now access your Netlify site\u2019s backend and edit content. Every edit is a commit on your repo, in the branch specified in your configuration file. If you kept your <code>main<\/code> branch as the target for Netlify CMS, each time you save, it will run a new build. More convenient, but not as clean with \u201cin-between states\u201d.<\/p>\n<p>Having it save on a <code>dev<\/code> branch allows you to have finer control on when you want to run a new build. This is especially important if your blog has a lot of content and requires a longer build time. Either way will work; <strong>it\u2019s just a matter of how you want to run your blog<\/strong>.<\/p>\n<p>Also, please note that Git LFS is something you installed locally, so images uploaded via Netlify CMS will be \u201cnormal\u201d. If you pull in your remote branch locally, the images should be converted to LFS, which you can then commit and push to your remote branch. Also, Netlify CMS does currently not support LFS so the image will not be displayed in the CMS, but they will show up on your final build.<\/p>\n<p><strong>Recommended reading<\/strong>: <em><a href=\"https:\/\/www.smashingmagazine.com\/2015\/11\/static-website-generators-jekyll-middleman-roots-hugo-review\/\">Static Site Generators Reviewed: Jekyll, Middleman, Roots, Hugo<\/a><\/em><\/p>\n<h3>Conclusion<\/h3>\n<p>What a ride! In this tutorial, you\u2019ve learned how to export your WordPress post to Markdown files, create a new repository, set up Git LFS, host a site on Netlify, generate a Hugo site, create your own theme and edit the content with Netlify CMS. Not too bad!<\/p>\n<p>What\u2019s next? Well, you could experiment with your Hugo setup and read more about the various tools Hugo offers \u2014 there are many that I didn\u2019t cover for the sake of brevity.<\/p>\n<p>Explore! Have fun! Blog!<\/p>\n<h4>Further Resources<\/h4>\n<ul>\n<li><a href=\"https:\/\/gohugo.io\/documentation\/\">Hugo Documentation<\/a>\n<ul>\n<li><a href=\"https:\/\/gohugo.io\/getting-started\/installing\/\">Installation<\/a><\/li>\n<li><a href=\"https:\/\/gohugo.io\/getting-started\/quick-start\/\">Quick Start<\/a><\/li>\n<li><a href=\"https:\/\/gohugo.io\/getting-started\/configuration\/\">Configuration<\/a><\/li>\n<li><a href=\"https:\/\/gohugo.io\/templates\/introduction\/\">Templating<\/a><\/li>\n<li><a href=\"https:\/\/gohugo.io\/content-management\/taxonomies\/\">Taxonomies<\/a><\/li>\n<li><a href=\"https:\/\/gohugo.io\/content-management\/shortcodes\/\">Shortcodes<\/a><\/li>\n<li><a href=\"https:\/\/gohugo.io\/hosting-and-deployment\/hosting-on-netlify\/\">Hugo on Netlify<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"https:\/\/www.netlify.com\/docs\/\">Netlify Documentation<\/a>\n<ul>\n<li><a href=\"https:\/\/www.netlify.com\/docs\/custom-domains\/\">Custom Domains<\/a><\/li>\n<li><a href=\"https:\/\/www.netlify.com\/docs\/dns\/\">Managed DNS<\/a><\/li>\n<li><a href=\"https:\/\/www.netlify.com\/docs\/netlify-toml-reference\/\">netlify.toml Deploy Scripts<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"https:\/\/www.netlifycms.org\/docs\/intro\/\">Netlify CMS Documentation<\/a>\n<ul>\n<li><a href=\"https:\/\/www.netlifycms.org\/docs\/widgets\/\">Widgets<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"https:\/\/git-lfs.github.com\/\">Git LFS<\/a><\/li>\n<\/ul>\n<div>\n  <img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/05\/logo-red-15.png?w=900\" alt=\"Smashing Editorial\"><span>(dm, yk, il)<\/span>\n<\/div>\n<\/article>\n<p class=\"wpematico_credit\"><small>Powered by <a href=\"http:\/\/www.wpematico.com\" target=\"_blank\">WPeMatico<\/a><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Switching From WordPress To Hugo Switching From WordPress To Hugo Christopher Kirk-Nielsen 2019-05-22T14:30:00+02:002019-05-23T11:05:56+00:00 When WordPress 5 was released, I was excited about making use of the Gutenberg editor to create custom blocks, as posts on my personal blog had a couple of features I could turn into a block, making it easier to set up&#8230;<a class=\"moretag\" href=\"https:\/\/www.taterboy.com\/blog\/2019\/05\/switching-from-wordpress-to-hugo\/\"> Read the full article&#8230;<\/a><\/p>\n","protected":false},"author":4,"featured_media":65801,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[371],"tags":[],"class_list":["post-65800","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-user-experience"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"Switching From WordPress To HugoSwitching From WordPress To Hugo Christopher Kirk-Nielsen 2019-05-22T14:30:00+02:002019-05-23T11:05:56+00:00When WordPress 5 was released, I was excited about making use of the Gutenberg editor to create custom blocks, as posts on my personal blog had a couple of features I could turn into a block, making it easier to set up my content.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Guest Contribution\"\/>\n\t<meta name=\"keywords\" content=\"user experience\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.taterboy.com\/blog\/2019\/05\/switching-from-wordpress-to-hugo\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Design for Immersive Technologies | User Experience for Games, Virtual Reality (VR) and Augmented\/Mixed Reality (AR\/MR)\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Switching From WordPress To Hugo | Design for Immersive Technologies\" \/>\n\t\t<meta property=\"og:description\" content=\"Switching From WordPress To HugoSwitching From WordPress To Hugo Christopher Kirk-Nielsen 2019-05-22T14:30:00+02:002019-05-23T11:05:56+00:00When WordPress 5 was released, I was excited about making use of the Gutenberg editor to create custom blocks, as posts on my personal blog had a couple of features I could turn into a block, making it easier to set up my content.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.taterboy.com\/blog\/2019\/05\/switching-from-wordpress-to-hugo\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-05-23T11:16:09+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2019-05-23T11:16:09+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Switching From WordPress To Hugo | Design for Immersive Technologies\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Switching From WordPress To HugoSwitching From WordPress To Hugo Christopher Kirk-Nielsen 2019-05-22T14:30:00+02:002019-05-23T11:05:56+00:00When WordPress 5 was released, I was excited about making use of the Gutenberg editor to create custom blocks, as posts on my personal blog had a couple of features I could turn into a block, making it easier to set up my content.\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/05\\\/switching-from-wordpress-to-hugo\\\/#article\",\"name\":\"Switching From WordPress To Hugo | Design for Immersive Technologies\",\"headline\":\"Switching From WordPress To Hugo\",\"author\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/author\\\/guestcontribution\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/www.taterboy.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/05\\\/1-wordpress-export.png?fit=400%2C178&ssl=1\",\"width\":400,\"height\":178},\"datePublished\":\"2019-05-23T04:16:09-07:00\",\"dateModified\":\"2019-05-23T04:16:09-07:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/05\\\/switching-from-wordpress-to-hugo\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/05\\\/switching-from-wordpress-to-hugo\\\/#webpage\"},\"articleSection\":\"User Experience\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/05\\\/switching-from-wordpress-to-hugo\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.taterboy.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/category\\\/user-experience\\\/#listItem\",\"name\":\"User Experience\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/category\\\/user-experience\\\/#listItem\",\"position\":2,\"name\":\"User Experience\",\"item\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/category\\\/user-experience\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/05\\\/switching-from-wordpress-to-hugo\\\/#listItem\",\"name\":\"Switching From WordPress To Hugo\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/05\\\/switching-from-wordpress-to-hugo\\\/#listItem\",\"position\":3,\"name\":\"Switching From WordPress To Hugo\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/category\\\/user-experience\\\/#listItem\",\"name\":\"User Experience\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/#organization\",\"name\":\"Design for Immersive Technologies\",\"description\":\"User Experience for Games, Virtual Reality (VR) and Augmented\\\/Mixed Reality (AR\\\/MR)\",\"url\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/author\\\/guestcontribution\\\/#author\",\"url\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/author\\\/guestcontribution\\\/\",\"name\":\"Guest Contribution\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/05\\\/switching-from-wordpress-to-hugo\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d2aad73eb0f48c67b141e9fc978a0e498969791ed623346e361d02d19775b0bb?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Guest Contribution\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/05\\\/switching-from-wordpress-to-hugo\\\/#webpage\",\"url\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/05\\\/switching-from-wordpress-to-hugo\\\/\",\"name\":\"Switching From WordPress To Hugo | Design for Immersive Technologies\",\"description\":\"Switching From WordPress To HugoSwitching From WordPress To Hugo Christopher Kirk-Nielsen 2019-05-22T14:30:00+02:002019-05-23T11:05:56+00:00When WordPress 5 was released, I was excited about making use of the Gutenberg editor to create custom blocks, as posts on my personal blog had a couple of features I could turn into a block, making it easier to set up my content.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/05\\\/switching-from-wordpress-to-hugo\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/author\\\/guestcontribution\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/author\\\/guestcontribution\\\/#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/www.taterboy.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/05\\\/1-wordpress-export.png?fit=400%2C178&ssl=1\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/05\\\/switching-from-wordpress-to-hugo\\\/#mainImage\",\"width\":400,\"height\":178},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/05\\\/switching-from-wordpress-to-hugo\\\/#mainImage\"},\"datePublished\":\"2019-05-23T04:16:09-07:00\",\"dateModified\":\"2019-05-23T04:16:09-07:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/\",\"name\":\"Design for Immersive Technologies\",\"description\":\"User Experience for Games, Virtual Reality (VR) and Augmented\\\/Mixed Reality (AR\\\/MR)\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Switching From WordPress To Hugo | Design for Immersive Technologies","description":"Switching From WordPress To HugoSwitching From WordPress To Hugo Christopher Kirk-Nielsen 2019-05-22T14:30:00+02:002019-05-23T11:05:56+00:00When WordPress 5 was released, I was excited about making use of the Gutenberg editor to create custom blocks, as posts on my personal blog had a couple of features I could turn into a block, making it easier to set up my content.","canonical_url":"https:\/\/www.taterboy.com\/blog\/2019\/05\/switching-from-wordpress-to-hugo\/","robots":"max-image-preview:large","keywords":"user experience","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.taterboy.com\/blog\/2019\/05\/switching-from-wordpress-to-hugo\/#article","name":"Switching From WordPress To Hugo | Design for Immersive Technologies","headline":"Switching From WordPress To Hugo","author":{"@id":"https:\/\/www.taterboy.com\/blog\/author\/guestcontribution\/#author"},"publisher":{"@id":"https:\/\/www.taterboy.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/05\/1-wordpress-export.png?fit=400%2C178&ssl=1","width":400,"height":178},"datePublished":"2019-05-23T04:16:09-07:00","dateModified":"2019-05-23T04:16:09-07:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/www.taterboy.com\/blog\/2019\/05\/switching-from-wordpress-to-hugo\/#webpage"},"isPartOf":{"@id":"https:\/\/www.taterboy.com\/blog\/2019\/05\/switching-from-wordpress-to-hugo\/#webpage"},"articleSection":"User Experience"},{"@type":"BreadcrumbList","@id":"https:\/\/www.taterboy.com\/blog\/2019\/05\/switching-from-wordpress-to-hugo\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/www.taterboy.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/#listItem","name":"User Experience"}},{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/#listItem","position":2,"name":"User Experience","item":"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog\/2019\/05\/switching-from-wordpress-to-hugo\/#listItem","name":"Switching From WordPress To Hugo"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog\/2019\/05\/switching-from-wordpress-to-hugo\/#listItem","position":3,"name":"Switching From WordPress To Hugo","previousItem":{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/#listItem","name":"User Experience"}}]},{"@type":"Organization","@id":"https:\/\/www.taterboy.com\/blog\/#organization","name":"Design for Immersive Technologies","description":"User Experience for Games, Virtual Reality (VR) and Augmented\/Mixed Reality (AR\/MR)","url":"https:\/\/www.taterboy.com\/blog\/"},{"@type":"Person","@id":"https:\/\/www.taterboy.com\/blog\/author\/guestcontribution\/#author","url":"https:\/\/www.taterboy.com\/blog\/author\/guestcontribution\/","name":"Guest Contribution","image":{"@type":"ImageObject","@id":"https:\/\/www.taterboy.com\/blog\/2019\/05\/switching-from-wordpress-to-hugo\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/d2aad73eb0f48c67b141e9fc978a0e498969791ed623346e361d02d19775b0bb?s=96&d=mm&r=g","width":96,"height":96,"caption":"Guest Contribution"}},{"@type":"WebPage","@id":"https:\/\/www.taterboy.com\/blog\/2019\/05\/switching-from-wordpress-to-hugo\/#webpage","url":"https:\/\/www.taterboy.com\/blog\/2019\/05\/switching-from-wordpress-to-hugo\/","name":"Switching From WordPress To Hugo | Design for Immersive Technologies","description":"Switching From WordPress To HugoSwitching From WordPress To Hugo Christopher Kirk-Nielsen 2019-05-22T14:30:00+02:002019-05-23T11:05:56+00:00When WordPress 5 was released, I was excited about making use of the Gutenberg editor to create custom blocks, as posts on my personal blog had a couple of features I could turn into a block, making it easier to set up my content.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.taterboy.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/www.taterboy.com\/blog\/2019\/05\/switching-from-wordpress-to-hugo\/#breadcrumblist"},"author":{"@id":"https:\/\/www.taterboy.com\/blog\/author\/guestcontribution\/#author"},"creator":{"@id":"https:\/\/www.taterboy.com\/blog\/author\/guestcontribution\/#author"},"image":{"@type":"ImageObject","url":"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/05\/1-wordpress-export.png?fit=400%2C178&ssl=1","@id":"https:\/\/www.taterboy.com\/blog\/2019\/05\/switching-from-wordpress-to-hugo\/#mainImage","width":400,"height":178},"primaryImageOfPage":{"@id":"https:\/\/www.taterboy.com\/blog\/2019\/05\/switching-from-wordpress-to-hugo\/#mainImage"},"datePublished":"2019-05-23T04:16:09-07:00","dateModified":"2019-05-23T04:16:09-07:00"},{"@type":"WebSite","@id":"https:\/\/www.taterboy.com\/blog\/#website","url":"https:\/\/www.taterboy.com\/blog\/","name":"Design for Immersive Technologies","description":"User Experience for Games, Virtual Reality (VR) and Augmented\/Mixed Reality (AR\/MR)","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.taterboy.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Design for Immersive Technologies | User Experience for Games, Virtual Reality (VR) and Augmented\/Mixed Reality (AR\/MR)","og:type":"article","og:title":"Switching From WordPress To Hugo | Design for Immersive Technologies","og:description":"Switching From WordPress To HugoSwitching From WordPress To Hugo Christopher Kirk-Nielsen 2019-05-22T14:30:00+02:002019-05-23T11:05:56+00:00When WordPress 5 was released, I was excited about making use of the Gutenberg editor to create custom blocks, as posts on my personal blog had a couple of features I could turn into a block, making it easier to set up my content.","og:url":"https:\/\/www.taterboy.com\/blog\/2019\/05\/switching-from-wordpress-to-hugo\/","article:published_time":"2019-05-23T11:16:09+00:00","article:modified_time":"2019-05-23T11:16:09+00:00","twitter:card":"summary","twitter:title":"Switching From WordPress To Hugo | Design for Immersive Technologies","twitter:description":"Switching From WordPress To HugoSwitching From WordPress To Hugo Christopher Kirk-Nielsen 2019-05-22T14:30:00+02:002019-05-23T11:05:56+00:00When WordPress 5 was released, I was excited about making use of the Gutenberg editor to create custom blocks, as posts on my personal blog had a couple of features I could turn into a block, making it easier to set up my content."},"aioseo_meta_data":{"post_id":"65800","title":null,"description":null,"keywords":null,"keyphrases":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_custom_image_width":null,"og_custom_image_height":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"location":null,"local_seo":null,"created":"2021-02-07 19:52:14","updated":"2026-09-01 11:08:45","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"primary_term":null,"og_image_url":null,"og_image_width":null,"og_image_height":null,"twitter_image_url":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.taterboy.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/\" title=\"User Experience\">User Experience<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tSwitching From WordPress To Hugo\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.taterboy.com\/blog"},{"label":"User Experience","link":"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/"},{"label":"Switching From WordPress To Hugo","link":"https:\/\/www.taterboy.com\/blog\/2019\/05\/switching-from-wordpress-to-hugo\/"}],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8wzr5-h7i","jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/05\/1-wordpress-export.png?fit=400%2C178&ssl=1","_links":{"self":[{"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/posts\/65800","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/comments?post=65800"}],"version-history":[{"count":0,"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/posts\/65800\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/media\/65801"}],"wp:attachment":[{"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/media?parent=65800"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/categories?post=65800"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/tags?post=65800"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}