You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

167 lines
3.8 KiB

4 years ago
  1. +++
  2. title = "Custom Homepage"
  3. description = "Hide the blog and specify how content is shown."
  4. categories = ["customizing"]
  5. tags = ["layout", "templating", "style", "metadata", "semantics", "robots"]
  6. features = ["code highlighter", "snippets", "related content"]
  7. [[copyright]]
  8. owner = "Josh Habdas"
  9. date = "2019"
  10. license = "agpl-3.0-or-later"
  11. +++
  12. After Dark provides a configurable way to customize the content shown on your homepage without the need for creating a [Custom Layout](../custom-layouts). Use it to hide the blog and display recent content from various sections of your site.
  13. {{< hackcss-alert >}}
  14. {{< figure
  15. src="/images/screenshots/feature-homepage-fs8.png"
  16. >}}
  17. {{< /hackcss-alert >}}
  18. {{< hackcss-card header="Quick Example" >}}
  19. {{< highlight toml "linenos=inline" >}}
  20. [params.layout.home]
  21. hide_blog = true
  22. [[params.layout.home.section]]
  23. type = "about"
  24. weight = 1
  25. [[params.layout.home.section]]
  26. type = "code" # Required, name of section to show on homepage
  27. limit = 4 # Optional, set number of items to show from section
  28. weight = 2 # Optional, choose layout order for section
  29. thumbs = ["fill", "400x400"] # Optional, thumbnail image processing
  30. [[params.layout.home.section]]
  31. type = "site"
  32. limit = 2
  33. weight = 3
  34. [[params.layout.home.section]]
  35. type = "post"
  36. limit = 3
  37. weight = 4
  38. {{< /highlight >}}
  39. {{< /hackcss-card >}}
  40. Start by adding a section to display:
  41. ```toml
  42. [[params.layout.home.section]]
  43. type = "post"
  44. ```
  45. Limit the number of items shown:
  46. ```toml
  47. [[params.layout.home.section]]
  48. type = "post"
  49. limit = 3
  50. ```
  51. Then hide the blog if you like:
  52. ```toml
  53. [params.layout.home]
  54. hide_blog = true
  55. ```
  56. And use the space to add more sections:
  57. ```toml
  58. [[params.layout.home.section]]
  59. type = "post"
  60. [[params.layout.home.section]]
  61. type = "podcast"
  62. ```
  63. Or add stand-alone pages too:
  64. ```toml
  65. [[params.layout.home.section]]
  66. type = "about"
  67. ```
  68. And display them in order by weight:
  69. ```toml
  70. [[params.layout.home.section]]
  71. type = "about"
  72. weight = 1
  73. [[params.layout.home.section]]
  74. type = "podcast"
  75. weight = 2
  76. ```
  77. With each section containing generic [Structured Data](../structured-data):
  78. ```
  79. Homepage
  80. ├── Thing
  81. └── ItemList
  82. ├── Thing
  83. ├── Thing
  84. └── Thing
  85. ```
  86. Which may be enhanced using front matter:
  87. ```
  88. ├── archetypes
  89. ├── content
  90. │ └── about.md
  91. │ └── podcast
  92. │ ├── _index.md
  93. │ ├── secrets-of-silicon-valley
  94. │ ├── the-5g-dragnet
  95. │ └── language-is-a-weapon
  96. ├── layouts
  97. ```
  98. ```toml
  99. title = "About"
  100. description = "Information about the site."
  101. [schema]
  102. type = "AboutPage" # inside about.md
  103. ```
  104. ```toml
  105. title = "Podcasts"
  106. description = "Live on the Web. Fresh to your head."
  107. [schema]
  108. type = "Audiobook" # inside _index.md
  109. ```
  110. Resulting in machine-readable structure:
  111. ```
  112. Homepage
  113. ├── AboutPage
  114. └── ItemList
  115. ├── Audiobook
  116. ├── Audiobook
  117. └── Audiobook
  118. ```
  119. Including `name` and `description` properties consistent between what's shown to users and what will appear in <abbr title="Search Engine Results Page">SERP</abbr>s.
  120. Item lists may include thumbnail images generated automatically for any `ItemList` element using a [Post Images](../post-images)-formatted resource bundle and containing `thumbnail` in the name:
  121. ```toml
  122. [[resources]]
  123. src = "**hyperdrive-logo.png"
  124. name = "header thumbnail"
  125. ```
  126. Images include high-performance defaults and may be modified using {{< external "https://gohugo.io/content-management/image-processing/#readout" "Hugo Image Processing" />}} via config using the `thumbs` property in site config:
  127. ```toml
  128. [[params.layout.home.section]]
  129. type = "code"
  130. thumbs = ["fill", "400x400"]
  131. ```
  132. Valid image processing options are `fit`, `resize` and `fill`, and image dimensions may be omitted for a 4x3 aspect ratio thumbnail.