From 5712e49125c893d18e6fea8d10494bacdc420c96 Mon Sep 17 00:00:00 2001 From: Maximilian Bosche Date: Wed, 10 Apr 2019 14:41:06 +0200 Subject: Order sections on homepage by weigth (#143) --- README.md | 2 ++ exampleSite/content/de/blog/_index.md | 1 + exampleSite/content/de/home/about.md | 2 +- exampleSite/content/de/home/lorem.md | 2 +- exampleSite/content/de/projects/_index.md | 1 + exampleSite/content/en/blog/_index.md | 3 ++- exampleSite/content/en/home/about.md | 4 ++-- exampleSite/content/en/home/lorem.md | 2 +- exampleSite/content/en/projects/_index.md | 3 ++- exampleSite/content/es/blog/_index.md | 1 + exampleSite/content/es/home/about.md | 2 +- exampleSite/content/es/home/lorem.md | 2 +- exampleSite/content/es/projects/_index.md | 1 + layouts/index.html | 22 ++++++++++++++++------ 14 files changed, 33 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 8390978..a01edaf 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,7 @@ hugo new projects/_index.md ``` Add a `title` and some optional content to the file. +Add an optional `weight` for ordering projects section. To create a project, run: @@ -122,6 +123,7 @@ Create an index file for the blog: ``` hugo new blog/_index.md ``` +Add an optional `weight` for ordering blog section on your homepage Create a new blog post with: diff --git a/exampleSite/content/de/blog/_index.md b/exampleSite/content/de/blog/_index.md index 8288dbd..a994abb 100644 --- a/exampleSite/content/de/blog/_index.md +++ b/exampleSite/content/de/blog/_index.md @@ -1,5 +1,6 @@ --- title: "Blog" +weight: 20 --- Ein Einleitungstext für meinen Blog diff --git a/exampleSite/content/de/home/about.md b/exampleSite/content/de/home/about.md index 7c9b833..a4c38e1 100644 --- a/exampleSite/content/de/home/about.md +++ b/exampleSite/content/de/home/about.md @@ -1,7 +1,7 @@ --- title: "Über mich" image: "profile.jpg" -weight: 0 +weight: 8 --- Dies ist **Vorstellung**, ein minimales Webseiten Theme für [Hugo](https://gohugo.io) diff --git a/exampleSite/content/de/home/lorem.md b/exampleSite/content/de/home/lorem.md index 17ffc75..04d7cb2 100644 --- a/exampleSite/content/de/home/lorem.md +++ b/exampleSite/content/de/home/lorem.md @@ -1,6 +1,6 @@ --- title: "Lorem Ipsum" -weight: 1 +weight: 30 --- Weitere Abschnitte für die Hauptseiten können hinzugefügt werden, indem Datein unter `content/home/` erstellt werden. diff --git a/exampleSite/content/de/projects/_index.md b/exampleSite/content/de/projects/_index.md index 58ed7d2..8e8ff68 100644 --- a/exampleSite/content/de/projects/_index.md +++ b/exampleSite/content/de/projects/_index.md @@ -1,5 +1,6 @@ --- title: "Projekte" +weight: 10 --- Ein Einleitungstext für meinen Projekte diff --git a/exampleSite/content/en/blog/_index.md b/exampleSite/content/en/blog/_index.md index 1ecac4c..a7c2af2 100644 --- a/exampleSite/content/en/blog/_index.md +++ b/exampleSite/content/en/blog/_index.md @@ -1,5 +1,6 @@ --- title: "Blog" +weight: 20 --- -Here is some introduction text for my blog. You can set this text in the `/blog/_index.md` file. This page uses the `/layouts/blog/list.html` template. \ No newline at end of file +Here is some introduction text for my blog. You can set this text in the `/blog/_index.md` file. This page uses the `/layouts/blog/list.html` template. diff --git a/exampleSite/content/en/home/about.md b/exampleSite/content/en/home/about.md index 6052d61..4161ab4 100644 --- a/exampleSite/content/en/home/about.md +++ b/exampleSite/content/en/home/about.md @@ -1,7 +1,7 @@ --- title: "About" image: "profile.jpg" -weight: 0 +weight: 8 --- This is **Introduction**, a minimalist website theme made for [Hugo](https://gohugo.io). @@ -14,4 +14,4 @@ This is **Introduction**, a minimalist website theme made for [Hugo](https://goh * Any number of custom index page sections from Markdown files * _Projects_ section with any number of projects: highly configurable as a photo gallery, modals, or external links * _Blog_ section with optional _Latest Post_, on the main page or as a separate section -* Styled Markdown throughout with support for Hugo's syntax highlighting \ No newline at end of file +* Styled Markdown throughout with support for Hugo's syntax highlighting diff --git a/exampleSite/content/en/home/lorem.md b/exampleSite/content/en/home/lorem.md index 824b327..5f57592 100644 --- a/exampleSite/content/en/home/lorem.md +++ b/exampleSite/content/en/home/lorem.md @@ -1,6 +1,6 @@ --- title: "Lorem Ipsum" -weight: 1 +weight: 30 --- You can add more sections to the home page by adding files to the `/content/home/` folder. diff --git a/exampleSite/content/en/projects/_index.md b/exampleSite/content/en/projects/_index.md index fdac72b..ca0a749 100644 --- a/exampleSite/content/en/projects/_index.md +++ b/exampleSite/content/en/projects/_index.md @@ -1,5 +1,6 @@ --- title: "Projects" +weight: 10 --- -Here is some introduction text for my projects. You can set this text in the `/projects/_index.md` file. This page uses the `/layouts/projects/list.html` template. \ No newline at end of file +Here is some introduction text for my projects. You can set this text in the `/projects/_index.md` file. This page uses the `/layouts/projects/list.html` template. diff --git a/exampleSite/content/es/blog/_index.md b/exampleSite/content/es/blog/_index.md index e95a00c..a62ffc0 100644 --- a/exampleSite/content/es/blog/_index.md +++ b/exampleSite/content/es/blog/_index.md @@ -1,5 +1,6 @@ --- title: "Blog" +weight: 20 --- Este es un texto introductorio para mi blog. diff --git a/exampleSite/content/es/home/about.md b/exampleSite/content/es/home/about.md index 7c6ab52..30a4676 100644 --- a/exampleSite/content/es/home/about.md +++ b/exampleSite/content/es/home/about.md @@ -1,7 +1,7 @@ --- title: "Sobre" image: "profile.jpg" -weight: 0 +weight: 8 --- Esto es **Introducción**, un tema mínimo con desplazamiento para sitios web hechos con [Hugo](https://gohugo.io). diff --git a/exampleSite/content/es/home/lorem.md b/exampleSite/content/es/home/lorem.md index f26ef4a..042bb42 100644 --- a/exampleSite/content/es/home/lorem.md +++ b/exampleSite/content/es/home/lorem.md @@ -1,6 +1,6 @@ --- title: "Lorem Ipsum" -weight: 1 +weight: 30 --- You can add more sections to the home page by adding file to `content/home/` diff --git a/exampleSite/content/es/projects/_index.md b/exampleSite/content/es/projects/_index.md index 31e8f35..159bb80 100644 --- a/exampleSite/content/es/projects/_index.md +++ b/exampleSite/content/es/projects/_index.md @@ -1,5 +1,6 @@ --- title: "Proyectos" +weight: 10 --- Este es un texto introductorio para mis proyectos. diff --git a/layouts/index.html b/layouts/index.html index ddbbb04..494e0d0 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -42,9 +42,22 @@ {{ with .Site.GetPage "/home" }} + + {{ $blog := .Site.GetPage "/blog" }} + {{ $projects := .Site.GetPage "/projects" }} {{ $home := . }} - {{ range sort (.Resources.ByType "page") "Params.weight" }} + + {{ $pages := sort (.Resources.ByType "page" | append $blog | append $projects) "Params.weight" }} + {{ range $pages }} {{ if ne .Name "contact.md" }} + {{ if eq .File.Dir "projects/" }} + + {{ partial "home/projects.html" . }} + {{ else if eq .File.Dir "blog/" }} + + {{ partial "home/blog.html" . }} + {{ else }} +
@@ -76,10 +89,7 @@
{{ end }} {{ end }} - - {{ partial "home/projects.html" . }} - - {{ partial "home/blog.html" . }} + {{ end }} {{ with .Resources.GetMatch "contact.md" }}
@@ -124,4 +134,4 @@ {{ end }} - \ No newline at end of file + -- cgit v1.2.3