Setting up blog

By: Dave Walsh

         hugo · blog      hugo · blog section      hugo zero to hero

Estimated reading time: 2 minutes

setting up the blog area of a hugo Site

  1. create a directory in the content directory called blog.
  2. add a section (in this case blog) index page using hugo command of hugo new blog/_index.md
    • in this page you only need to have the front matter
  3. add new blog content pages.
    • can use hugo command of hugo new blog/blogtitile.md
    • add content in markdown to the new md file
  4. create a similar folder structure in the layouts directory to that in the content directory ( “/layouts/blog/” similar to “/content/blog/”)
  5. create a list.md and single.md template files in this new layouts/blog direcrory
  6. in the list.md add
{{ partial "homepage-header.html" . }}

<h2>{{ .Title }} {{ if .GetParam "draft"}}DRAFT{{end}}</h2>

<ul class="articles-list">
    <!-- Ranges through content/blog/*.md -->
    {{ range (.Paginator 5).Pages }}
    <li class="post">
        <a class="post-title" href="{{.RelPermalink}}">{{ .Title }}</a>
        <span class="post-meta"><time>{{ .Date.Format "January 2, 2006" }}</time> {{ if .Params.External }} — <span class="post-host">for {{ .Params.External.Host }}</span> {{ end }}</span>

        <div class="post-summary">
            {{ .Summary }} <!-- automatically takes the first paragraph in the .md article -->
        </div>

        <p><small><a href="{{.RelPermalink}}" class="read-more-link">Read more ››</a></small></p>
    </li>

    {{ end }}
</ul>

{{ partial "pagination.html" . }}
{{ partial "footer.html" . }}
{{ partial "homepage-header.html" . }}

<h1>{{ .Title }}</h1>

{{ .Content }}

{{ partial "footer.html" . }}

using categories and tags


Part 7 of 15 in the hugo zero to hero series.

Series Start | Hugo Markdown | Autonav