TL;DR — This article will show you how to a simple website to a static site generator ( ) and host it for free on either or . migrate WordPress Hugo Netlify GitHub Pages / GitHub Repository for this demo Demo Site Jump to Getting Started What is Hugo? Hugo Logo Hugo is a static HTML and CSS website generator written in Go. It is optimized for speed, ease of use, and configurability. Hugo takes a directory with content and templates and renders them into a full HTML website. Hugo relies on Markdown files with front matter for metadata, and you can run Hugo from any directory. This works well for shared hosts and other systems where you don’t have a privileged account. Hugo renders a typical website of moderate size in a fraction of a second. A good rule of thumb is that each piece of content renders in around 1 millisecond.Hugo is designed to work well for any kind of website including blogs, tumbles, and docs. ( ) https://github.com/gohugoio/hugo#overview What is GitHub Pages? GitHub Pages is a static site hosting service designed to host your personal, organization, or project pages directly from a GitHub repository. ( ) https://help.github.com/articles/what-is-github-pages/ What is Netlify? Netlify is perfecting a unified platform that automates your code to create high-performant, easily-maintainable sites and web-apps. ( ) https://www.netlify.com/press/ Getting Started To get started, you will need to for your Hugo project. create a new GitHub repository Inside the repository, we will create a new hugo site. Steps: Install Hugo: brew install hugo 2. Create a New Site in your repository’s directory: hugo new site . --force 3. Add a Theme (the current theme I am using is called ): sustain git clone https://github.com/nurlansu/hugo-sustain.git themes/hugo-sustain 4. Update the config.toml file (depending on your theme): baseurl = " "languageCode = "en-US"title = "Hugo Site"disqusShortname = ""googleAnalytics = ""theme = "hugo-sustain" https://hugo-blog-demo.netlify.com/ [permalinks]post = "/:year/:month/:day/:slug" [params]avatar = "profile.png"author = "Author Name"description = "Describe your website" custom_css = []custom_js = [] [params.social]Github = "username"Email = " "Twitter = "username"LinkedIn = "username"Stackoverflow = "username"Medium = "username"Telegram = "username" email@example.com [[menu.main]]name = "blog"weight = 100identifier = "blog"url = "/blog/"[[menu.main]]name = "projects"identifier = "projects"weight = 200url = "/projects/"[[menu.main]]name = "resume"identifier = "resume"weight = 300url = "/resume/" 5. Add Content: hugo new blog/my-first-post.md When you serve your website locally, you should be able to see the Hugo site up and running. hugo server localhost:1313/blog WordPress Migration You can skip to the if you are not migrating a website to Hugo. Website Deployment section WordPress Exporting the Content We will be the to migrate current WordPress content over to Hugo. This plugin converts all your posts, pages, images, and content on WordPress into files that will work with Hugo. Jekyll Exporter WordPress plugin Now we can copy over the converted blog post files exported from the plugin into Hugo, inside . /content/blog Keeping the Images To keep any images, you can copy over the exported folder into the folder in your Hugo project. Anything inside the folder can be referenced relatively. Example: wp-content static static /wp-content/uploads/image.jpg If you have any blog posts referencing these images, you can do a find a replace inside the Hugo project to replace your WordPress website’s absolute path with a relative path. Example: will be changed to http://wordpress-domain.com/wp-content/uploads/image.jpg /wp-content/uploads/image.jpg Migrated Blog Post Website Deployment To host and deploy your Hugo website for free. You can either use or . Netlify GitHub Pages Netlify Steps to deploy using Netlify: First for a Netlify account. signup linked to your repository. Create a new site GitHub Select your options and deploy. After you hit deploy, it should build and deploy to a Netlify subdomain. Netlify also comes with Continuous Deployment, on how you set it up. By default, every time you push to Github, Netlify builds the master branch of your repository and deploys to Netlify’s Content Delivery Networks (CDNs). depending Example: each time a commit is pushed to the master branch of Netlify builds and deploys to my repository https://hugo-blog-demo.netlify.com/ Furthermore, you can add your own to Netlify. custom domain GitHub Pages Steps to deploy using : GitHub Pages Create another repository with to host the Hugo website. <username>.github.io In your original Hugo project repository, add your repository as a submodule: <username>.github.io git submodule add -b master :<username>/<username>.github.io.git publicgit push git@github.com 3. Create a deploy script called in the root of your Hugo project repository: deploy.sh #!/bin/bash echo -e "\033[0;32mDeploying updates to GitHub...\033[0m" # Build the project.hugo -t hugo-sustain --baseURL=" " # if using a theme, replace by `hugo -t <yourtheme>` https://hugo-demo.github.io/ # Go To Public foldercd public# Add changes to git.git add -A # Commit changes.msg="rebuilding site `date`"if [ $# -eq 1 ]then msg="$1"figit commit -m "$msg" # Push source and build repos.git push origin master # Come Backcd .. 4. Run the deploy script: sh deploy.sh 5. The site should now be deployed at https://<username>.github.io if you want to use project pages or deploy from a different branch. More on GitHub page deploys https://hugo-blog-demo.netlify.com/ / GitHub Repository for this demo Demo Site Software Developer Phong Huynh @xphong