HUGO

  • Новости
  • Документация
  • Темы
  • Витрина
  • Сообщество
  • GitHub
  • Telegram
Star

Что на этой странице

  • Вложенные разделы
  • Пример: Навигация по хлебным крошкам
  • Переменные и методы страницы раздела
  • Списки разделов контента
  • Контент Раздел vs Контент Тип
CONTENT MANAGEMENT

Разделы контента

Хьюго создает дерево разделов, соответствующее Вашему контенту.

Раздел - это набор страниц, который определяется на основе организационной структуры в каталоге content/.

По умолчанию все каталоги первого уровня в разделе content/ образуют свои собственные разделы (корневые разделы).

Если пользователю необходимо определить раздел foo на более глубоком уровне, ему нужно создать каталог с именем foo с файлом _index.md (смотрите связки веток для получения дополнительной информации).

Раздел не может быть определен или переопределен параметром первичного сообщения — он строго определяется структурой организации контента.

Вложенные разделы

Разделы могут быть вложены настолько глубоко, насколько Вам нужно.

content
└── blog        <-- Section, because first-level dir under content/
    ├── funny-cats
    │   ├── mypost.md
    │   └── kittens         <-- Section, because contains _index.md
    │       └── _index.md
    └── tech                <-- Section, because contains _index.md
        └── _index.md

Важно понимать, что для того, чтобы дерево разделов было полностью навигационным, по крайней мере, для самого нижнего раздела требуется файл содержимого. (например, _index.md).

Когда мы говорим о разделе в корреляции с выбором шаблона, в настоящее время это всегда только корневой раздел (/blog/funny-cats/mypost/ => blog).

Если Вам нужен конкретный шаблон для подраздела, Вам нужно настроить либо type, либо layout во front matter.

Пример: Навигация по хлебным крошкам

С помощью доступных переменных и методов раздела Вы можете создать мощную навигацию. Одним из распространенных примеров может быть частичное отображение навигации хлебных крошек:

layouts/partials/breadcrumb.html

<ol  class="nav navbar-nav">
  {{ template "breadcrumbnav" (dict "p1" . "p2" .) }}
</ol>
{{ define "breadcrumbnav" }}
{{ if .p1.Parent }}
{{ template "breadcrumbnav" (dict "p1" .p1.Parent "p2" .p2 )  }}
{{ else if not .p1.IsHome }}
{{ template "breadcrumbnav" (dict "p1" .p1.Site.Home "p2" .p2 )  }}
{{ end }}
<li{{ if eq .p1 .p2 }} class="active"{{ end }}>
  <a href="{{ .p1.Permalink }}">{{ .p1.Title }}</a>
</li>
{{ end }}

Переменные и методы страницы раздела

Смотрите также переменные страницы.

.CurrentSection
The page’s current section. The value can be the page itself if it is a section or the homepage.
.FirstSection
The page’s first section below root, e.g. /docs, /blog etc.
.InSection $anotherPage
Whether the given page is in the current section.
.IsAncestor $anotherPage
Whether the current page is an ancestor of the given page.
.IsDescendant $anotherPage
Whether the current page is a descendant of the given page.
.Parent
A section’s parent section or a page’s section.
.Section
The section this content belongs to. Note: For nested sections, this is the first path element in the directory, for example, /blog/funny/mypost/ => blog.
.Sections
The sections below this content.

Списки разделов контента

Hugo автоматически создаст страницы для каждого корневого раздела, на котором будет перечислено все содержимое этого раздела. Смотрите документацию по шаблонам раздела для получения подробной информации о настройке способа отображения этих страниц.

Контент Раздел vs Контент Тип

По умолчанию все, что создано в разделе, будет использовать контент type, который соответствует имени корневого раздела. Например, Хьюго предположит, что posts/post-1.md имеет контент posts типа type. Если Вы используете архитипы для своего раздела posts, Hugo сгенерирует главный материал в соответствии с тем, что он находит в archetypes/posts.md.

Смотрите также

  • Типы контента
  • .GetPage
  • Lists of Content in Hugo
  • Menu Templates
  • Pagination
  • О Хьюго
    • Обзор
    • Модель безопасности Хьюго
    • Hugo и GDPR
    • Что такое Хьюго
    • Функции Хьюго
    • Преимущества статики
    • Лицензия
  • С чего начать
    • Обзор начала работы
    • Быстрый старт
    • Установка Хьюго
    • Основы использования
    • Структура каталогов
    • Настройка
    • Внешние ресурсы обучения
  • Модули Хьюго
    • Обзор модулей Hugo
    • Настройка модулей
    • Использование модулей Hugo
    • Компоненты темы
  • Управление контентом
    • Обзор управления контентом
    • Организация
    • Пакеты страниц
    • Форматы контента
    • Front Matter
    • Page Resources
    • Параметры сборки
    • Обработка изображений
    • Шорткоды
    • Связанный контент
    • Разделы
    • Типы контента
    • Архетипы
    • Таксономии
    • Содержание
    • Ссылки и перекрестные ссылки
    • Управление URL-адресами
    • Меню
    • Статические файлы
    • Комментарии
    • Многоязычный и i18n
    • Подсветка синтаксиса
  • Templates
    • Templates Overview
    • Introduction
    • Template Lookup Order
    • Custom Output Formats
    • Base Templates and Blocks
    • List Page Templates
    • Homepage Template
    • Section Templates
    • Taxonomy Templates
    • Single Page Templates
    • Content View Templates
    • Data Templates
    • Partial Templates
    • Shortcode Templates
    • Local File Templates
    • 404 Page
    • Menu Templates
    • Pagination
    • RSS Templates
    • Sitemap Template
    • Robots.txt
    • Internal Templates
    • Alternative Templating
    • Template Debugging
  • Functions
    • Functions Quick Reference
    • .AddDate
    • .Format
    • .Get
    • .GetPage
    • .HasMenuCurrent
    • .IsMenuCurrent
    • .Param
    • .Render
    • .RenderString
    • .Scratch
    • .Unix
    • absLangURL
    • absURL
    • after
    • anchorize
    • append
    • apply
    • base64
    • chomp
    • complement
    • cond
    • countrunes
    • countwords
    • dateFormat
    • default
    • delimit
    • dict
    • echoParam
    • emojify
    • eq
    • errorf and warnf
    • fileExists
    • findRE
    • first
    • float
    • ge
    • getenv
    • group
    • gt
    • hasPrefix
    • highlight
    • hmac
    • htmlEscape
    • htmlUnescape
    • hugo
    • humanize
    • i18n
    • Image Functions
    • in
    • index
    • int
    • intersect
    • isset
    • jsonify
    • lang.Merge
    • lang.NumFmt
    • last
    • le
    • len
    • lower
    • lt
    • markdownify
    • Math
    • md5
    • merge
    • ne
    • now
    • os.Stat
    • partialCached
    • path.Base
    • path.Dir
    • path.Ext
    • path.Join
    • path.Split
    • plainify
    • pluralize
    • print
    • printf
    • println
    • querify
    • range
    • readDir
    • readFile
    • ref
    • reflect.IsMap
    • reflect.IsSlice
    • relLangURL
    • relref
    • relURL
    • replace
    • replaceRE
    • safeCSS
    • safeHTML
    • safeHTMLAttr
    • safeJS
    • safeURL
    • seq
    • sha
    • shuffle
    • singularize
    • slice
    • slicestr
    • sort
    • split
    • string
    • strings.Count
    • strings.HasSuffix
    • strings.Repeat
    • strings.RuneCount
    • strings.TrimLeft
    • strings.TrimPrefix
    • strings.TrimRight
    • strings.TrimSuffix
    • substr
    • symdiff
    • templates.Exists
    • time
    • title
    • transform.Unmarshal
    • trim
    • truncate
    • union
    • uniq
    • upper
    • urlize
    • urls.Parse
    • where
    • with
  • Variables
    • Variables Overview
    • Site Variables
    • Page Variables
    • Shortcode Variables
    • Pages Methods
    • Taxonomy Variables
    • File Variables
    • Menu Entry Properties
    • Hugo Variables
    • Git Variables
    • Sitemap Variables
  • Hugo Pipes
    • Hugo Pipes Overview
    • Hugo Pipes Introduction
    • SASS / SCSS
    • PostProcess
    • PostCSS
    • JavaScript Building
    • Babel
    • Asset minification
    • Asset bundling
    • Fingerprinting and SRI
    • Resource from Template
    • Resource from String
  • CLI
  • Troubleshooting
    • Troubleshoot
    • FAQ
    • Build Performance
  • Tools
    • Developer Tools Overview
    • Migrations
    • Starter Kits
    • Frontends
    • Editor Plug-ins
    • Search
    • Other Projects
  • Hosting & Deployment
    • Hosting & Deployment Overview
    • Hugo Deploy
    • Host-Agnostic Deploys with Nanobox
    • Host on AWS Amplify
    • Host on Netlify
    • Host on Render
    • Host on Firebase
    • Host on GitHub
    • Host on GitLab
    • Hosting on KeyCDN
    • Host on Bitbucket
    • Deployment with Wercker
    • Deployment with Rsync
  • Contribute
    • Contribute to Hugo
    • Development
    • Documentation
    • Themes
  • Maintenance
“Разделы контента” последнее обновление: December 28, 2020: Перевод части content-management (295a8fcfc)
Улучшить эту страницу
Авторы Hugo
Hugo Logo
  • Подать вопрос
  • Получить помощь
  • Обсудить исходный код
  • @GoHugoIO
  • @spf13
  • @bepsays
 
 

Спонсоры Hugo

Logo for Forestry.io
Logo for Linode
Logo for eSolia
 

Авторские права на логотипы Hugo принадлежат © Steve Francia 2013–2021.

Hugo Gopher основан на оригинальной работе Renée French.

  • Новости
  • Документация
  • Темы
  • Витрина
  • Сообщество
  • GitHub
  • Telegram
  • О Хьюго
  • С чего начать
  • Модули Хьюго
  • Управление контентом
  • Templates
  • Functions
  • Variables
  • Hugo Pipes
  • CLI
  • Troubleshooting
  • Tools
  • Hosting & Deployment
  • Contribute
  • Maintenance