diff options
author | Alexander Eble <35292572+alexanderdavide@users.noreply.github.com> | 2021-06-20 22:22:56 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-20 22:22:56 +0300 |
commit | a9c96151e0593be2c2984ee04d4cbf3a9ded9dae (patch) | |
tree | 0d93064ec23612bce044d06e478285518a89bb31 | |
parent | f641c9dc6baee00d08fa955dd3fd60b23e589af2 (diff) |
Add Option for Main Section Heading (#216)v1.1.0
Added an option to define a section heading for the posts on the frontpage through the _index.md file.
Co-authored-by: Alexander Bilz <mail@alexbilz.com>
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | exampleSite/content/arabic/_index.md | 3 | ||||
-rw-r--r-- | exampleSite/content/english/_index.md | 3 | ||||
-rw-r--r-- | layouts/index.html | 8 |
4 files changed, 15 insertions, 2 deletions
@@ -513,6 +513,9 @@ You can configure the pages shown on the front page by altering the `mainSection mainSections = ["post", "docs"] ``` +### _index.md and post section header +You can place custom content, by creating `_index.md` markdown file within the content directory. An example can be found [here](https://github.com/lxndrblz/anatole/blob/exampleSite/content/english/_index.md). Uncomment the section as needed. This file `_index.md` also has a parameter called `mainSectionsTitle`, which lets you specify a header for the posts on the main page. This header will be styled and placed always after the content of the `_index.md` it self. + ### Robots.txt If you want Hugo to generate a robots.txt, you will have to set the `enableRobotsTXT` in the `config.toml` to `true`. By default, a robots.txt, which allows search engine crawlers to access to any page, will be generated. It will look like this: diff --git a/exampleSite/content/arabic/_index.md b/exampleSite/content/arabic/_index.md index 3e127b3..daa8952 100644 --- a/exampleSite/content/arabic/_index.md +++ b/exampleSite/content/arabic/_index.md @@ -3,7 +3,7 @@ author = "Hugo Authors" +++ <!-- -This file is left intentionally empty by default to be backward compatible with initial theme setup. +This file is left intentionally empty by default to be backwards compatible with the initial theme setup. Although the theme has advanced a little bit and it now allows to specify the content on the main page (even if the list of posts/articles is not intended). This can be: @@ -21,4 +21,5 @@ Markdown supported, ie: Don't forget to check the README.md file! ``` +Remember that you can also specify a section header for the posts below by configuring the `mainSectionsTitle` parameter in the front matter of this file. --> diff --git a/exampleSite/content/english/_index.md b/exampleSite/content/english/_index.md index 3e127b3..daa8952 100644 --- a/exampleSite/content/english/_index.md +++ b/exampleSite/content/english/_index.md @@ -3,7 +3,7 @@ author = "Hugo Authors" +++ <!-- -This file is left intentionally empty by default to be backward compatible with initial theme setup. +This file is left intentionally empty by default to be backwards compatible with the initial theme setup. Although the theme has advanced a little bit and it now allows to specify the content on the main page (even if the list of posts/articles is not intended). This can be: @@ -21,4 +21,5 @@ Markdown supported, ie: Don't forget to check the README.md file! ``` +Remember that you can also specify a section header for the posts below by configuring the `mainSectionsTitle` parameter in the front matter of this file. --> diff --git a/layouts/index.html b/layouts/index.html index 1e2aaa0..a09d3bc 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -13,6 +13,14 @@ --> </div> + {{ if .Params.mainSectionsTitle }} + <div class="post {{ with .Site.Params.doNotLoadAnimations }} . {{ else }} animated fadeInDown {{ end }}"> + <div class="post-title post-content"> + <h2>{{ .Params.mainSectionsTitle }}</h2> + </div> + </div> + {{ end }} + {{ $paginator := .Paginate (where .Site.RegularPages "Type" "in" .Site.Params.mainSections) }} {{ range $paginator.Pages }} |