Минимальный комплект шаблонов Hugo

Матеріал з Wiki.Zina
Версія від 08:34, 11 серпня 2017, створена >WikiSysop
(різн.) ← Попередня версія | Поточна версія (різн.) | Новіша версія → (різн.)
Перейти до навігації Перейти до пошуку

←Hugo

├── content/
│   └── index.md
└── layouts/
    ├── index.html
    ├── _default/
    │   └── single.html
    └── partial/
        ├── html-head.html
        ├── header.html
        └── footer.html

content/index.md

[ред. | ред. код]
---
title: Заголовок title главной страницы 
type: homepage
---

## Заголовок H1 главной страницы

Текст главной страницы.

layouts/index.html

[ред. | ред. код]
{{ partial "header" . }}

<!-- Content. Is the actual content of 'content/index.md' -->

{{ range where .Data.Pages "Type" "homepage" }}
  <h1>{{ .Title }}</h1>
  {{ .Content }}
{{ end }}

{{ partial "footer" . }}

layouts/partial/header.html

[ред. | ред. код]
<!DOCTYPE html>
<html lang="ru">
<head>
  <meta charset="utf-8">
  <title> {{ .Site.Title }}</title>
  <meta name="description" content="{{ .Site.Description }}">
  <link rel="icon" href="/favicon.ico">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="{{ .Site.BaseURL }}css/style.css">
</head>
<body>

layouts/partial/footer.html

[ред. | ред. код]
</body>
</html>

layouts/_default/single.html

[ред. | ред. код]
{{ partial "header.html" . }}

<h1>{{ .Title }}</h1>
{{ .Content }}

{{ partial "footer.html" . }}