Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Commit

Permalink
make use of page bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
Lenard Gaida committed Oct 4, 2019
1 parent bd8907e commit 2197141
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,26 @@ Inside the folder of your Hugo site run:
$ git clone https://github.com/lgaida/mediumish-gohugo-theme

## Preface
Most image files should be placed somewhere within the `static` folder of your gohugo website. This allows them to be easily referenced from the config.toml or post.md files. You may structure the files and folders within `static` however you'd like, with one exception: There must be a file named `jumbotron.jpg` present under the path `static/images` as it is referenced in the .css.
I recommend placing image files for your site config within the `static` folder of your gohugo website. This allows them to be easily referenced from the config.toml or post.md files. You may structure the files and folders within `static` however you'd like, with one exception: There must be a file named `jumbotron.jpg` present under the path `static/images` as it is referenced in the .css.


## Post Example
To create a simple post use the hugo new command as usual.
This theme makes use of page bundles / page resource (see https://gohugo.io/content-management/page-bundles/).
Place any image next to your post's index.md file and make sure it contains the keyword "cover" inside its name.
This image will also be used for twitter and opengraph cards.

```
hugo new blog/my-first-post.md
hugo new blog/my-first-post/index.md
```

You then have a few options which i want to point out in the following.
Creating a new post will create something like this:
```
---
title: "My first post"
date: 2018-10-01T15:25:19+02:00
publishdate: 2018-10-07T11:17:14+02:00
lastmod: 2018-10-08T18:55:29+02:00
image: "/images/Test.jpg"
tags: ["post", "interesting"]
type: "post"
comments: false
Expand All @@ -54,7 +57,6 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean semper libero qu

`publishdate`: is displayed at the top of the single-view\
`lastmod`: is displayed as a hint on the single-view\
`image`: is displayed in the list- and single-view\
`tags`: are used as usual, just add the tags you want to use. They are displayed in the jumbotron on the list-view, and on the bottom of each single-view\
`comments`: true/false to turn on/off disqus-comments

Expand Down
3 changes: 1 addition & 2 deletions archetypes/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
publishdate: {{ .Date }}
image: ""
tags:[]
tags: []
comments: true
draft: true
---
7 changes: 4 additions & 3 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ <h1 class="posttitle">{{ .Title }}</h1>
</div>

<!-- Post Featured Image -->
{{with .Params.image}}
<img class="featured-image img-fluid" src="{{ . | urlize | relURL }}" alt="thumbnail for this post">
{{$images := .Resources.ByType "image"}}
{{with $images.GetMatch "*cover*" }}
<img class="featured-image img-fluid" src="{{ .Permalink }}" alt="thumbnail for this post">
{{end}}
<!-- End Featured Image -->

<!-- Post Content -->
<div class="article-post">
{{ .Content}}
Expand Down
5 changes: 3 additions & 2 deletions layouts/partials/list-partials/postbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
<div class="card h-100">
<div class="maxthumb">
<a href="{{ .URL }}">
{{with .Params.image}}
<img class="img-fluid" src="{{ . | urlize | relURL }}" alt="A thumbnail image">
{{$images := .Resources.ByType "image"}}
{{with $images.GetMatch "*cover*" }}
<img class="img-fluid" src="{{ .Permalink }}" alt="A thumbnail image">
{{end}}
</a>
</div>
Expand Down

0 comments on commit 2197141

Please sign in to comment.