mirror of https://github.com/lxndrblz/anatole.git

Alexander Eble
20.22.2021 a9c96151e0593be2c2984ee04d4cbf3a9ded9dae
Add Option for Main Section Heading (#216)

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>
4 files modified
17 ■■■■ changed files
README.md 3 ●●●●● patch | view | raw | blame | history
exampleSite/content/arabic/_index.md 3 ●●●● patch | view | raw | blame | history
exampleSite/content/english/_index.md 3 ●●●● patch | view | raw | blame | history
layouts/index.html 8 ●●●●● patch | view | raw | blame | history
README.md
@@ -513,6 +513,9 @@
  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:
exampleSite/content/arabic/_index.md
@@ -3,7 +3,7 @@
+++
<!--
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 @@
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.
-->
exampleSite/content/english/_index.md
@@ -3,7 +3,7 @@
+++
<!--
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 @@
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.
-->
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 }}