Making a hugo powered blog in emacs

2020/04/22

Starting a blog this days couldn’t be easier. Ten simple steps to get started.

  1. Create a github pages repo.

    Check it out locally, e.g. to ~/blog. Every file you put in the repo will be published automatically:

    By default, Jekyll doesn’t build files or folders that:

    • are located in a folder called /node_modules or /vendor
    • start with _, ., or #
    • end with ~
    • are excluded by the exclude setting in your configuration file
  2. Configure custom domain or just use the default <repo>.github.io.

  3. Create ~/blog/_hugo/config.toml

        baseURL = "http://sarg.org.ru/"
        languageCode = "en-us"
        title = "Random forest"
        theme = "anubis" # see the next step
        publishDir = "../" # github pages look in the root folder by default
    
  4. Checkout some theme.

        git submodule add   \
        https://github.com/Mitrichius/hugo-theme-anubis.git \
        _hugo/themes/anubis
    
  5. Add _hugo/content to .gitignore.

    This directory will be generated by ox-hugo, no need to store it in git.

  6. Create org-mode file where all the content would be placed.

    Use the instruction from ox-hugo documentation. But make sure that #+HUGO_BASE_DIR points to _hugo directory. You can put the file whenever you want, not strictly necessary in the repository.

  7. Export the file with ox-hugo.

    Press C-c C-e H A to export everything. Now _hugo/content should be populated. You might want to enable auto export on saving.

  8. Check that your blog works locally.

    Go to _hugo/ and run hugo server -D. Hugo should start on http://localhost:1313

  9. Generate html for github pages.

    Run hugo and it’ll create all the files in publishDir.

  10. Commit and push all the changes. You’re done! 🎉