debian-mirror-gitlab/doc/development/documentation/site_architecture/global_nav.md

305 lines
12 KiB
Markdown
Raw Normal View History

2019-02-15 15:39:39 +05:30
---
2021-01-29 00:20:46 +05:30
stage: none
group: unassigned
2021-02-22 17:27:13 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2019-02-15 15:39:39 +05:30
description: "Learn how GitLab docs' global navigation works and how to add new items."
---
# Global navigation
2020-03-13 15:44:24 +05:30
> - [Introduced](https://gitlab.com/gitlab-org/gitlab-docs/-/merge_requests/362) in GitLab 11.6.
> - [Updated](https://gitlab.com/gitlab-org/gitlab-docs/-/merge_requests/482) in GitLab 12.1.
> - [Per-project](https://gitlab.com/gitlab-org/gitlab-docs/-/merge_requests/498) navigation added in GitLab 12.2.
2021-04-29 21:17:54 +05:30
> - [Unified global navigation](https://gitlab.com/gitlab-org/gitlab-docs/-/merge_requests/1482) added in GitLab 13.11.
2019-02-15 15:39:39 +05:30
2021-09-30 23:02:18 +05:30
Global navigation is the left-most pane in the documentation. You can use the
"global nav" to browse the content.
2019-02-15 15:39:39 +05:30
2021-09-30 23:02:18 +05:30
Research shows that people use Google to search for GitLab product documentation. When they land on a result,
we want them to find topics nearby that are related to the content they're reading. The global nav provides this information.
2019-02-15 15:39:39 +05:30
2021-09-30 23:02:18 +05:30
At the highest level, our global nav is workflow-based. Navigation needs to help users build a mental model of how to use GitLab.
The levels under each of the higher workflow-based topics are the names of features.
For example:
**Use GitLab** (_workflow_) **> Build your application** (_workflow_) **> CI/CD** (_feature_) **> Pipelines** (_feature)
## Choose the right words for your navigation entry
Before you add an item to the left nav, choose the parts of speech you want to use.
The nav entry should match the page title. However, if the title is too long,
when you shorten the phrase, use either:
- A noun, like **Merge requests**.
- An active verb, like **Install GitLab** or **Get started with runners**.
Use a phrase that clearly indicates what the page is for. For example, **Get started** is not
as helpful as **Get started with runners**.
## Add a navigation entry
All topics should be included in the left nav.
2019-02-15 15:39:39 +05:30
2021-04-29 21:17:54 +05:30
To add a topic to the global nav, edit
2021-09-04 01:27:46 +05:30
[`navigation.yaml`](https://gitlab.com/gitlab-org/gitlab-docs/blob/main/content/_data/navigation.yaml)
2021-04-29 21:17:54 +05:30
and add your item.
2021-09-30 23:02:18 +05:30
All new pages need a navigation item. Without a navigation, the page becomes "orphaned." That
2019-12-04 20:38:33 +05:30
is:
2019-02-15 15:39:39 +05:30
2019-12-04 20:38:33 +05:30
- The navigation shuts when the page is opened, and the reader loses their place.
- The page doesn't belong in a group with other pages.
2019-02-15 15:39:39 +05:30
2019-12-04 20:38:33 +05:30
This means the decision to create a new page is a decision to create new navigation item and vice
versa.
2019-02-15 15:39:39 +05:30
2019-12-04 20:38:33 +05:30
### Where to add
Documentation pages can be said to belong in the following groups:
- GitLab users. This is documentation for day-to-day use of GitLab for users with any level
of permissions, from Reporter to Owner.
- GitLab administrators. This tends to be documentation for self-managed instances that requires
access to the underlying infrastructure hosting GitLab.
- Other documentation. This includes documentation for customers outside their day-to-day use of
GitLab and for contributors. Documentation that doesn't fit in the other groups belongs here.
With these groups in mind, the following are general rules for where new items should be added.
- User documentation for:
- Group-level features belongs under **Groups**.
- Project-level features belongs under **Projects**.
- Features outside a group or project level (sometimes called "instance-level") can be placed at
the top-level, but care must be taken not to overwhelm that top-level space. If possible, such
features could be grouped in some way.
- Outside the above, most other miscellaneous user documentation belongs under **User**.
- Administration documentation belongs under **Administrator**.
- Other documentation belongs at the top-level, but care must be taken to not create an enormously
long top-level navigation, which defeats the purpose of it.
Making all documentation and navigation items adhere to these principles is being progressively
rolled out.
### What to add
Having decided where to add a navigation element, the next step is deciding what to add. The
mechanics of what is required is [documented below](#data-file) but, in principle:
- Navigation item text (that which the reader sees) should:
- Be as short as possible.
- Be contextual. It's rare to need to repeat text from a parent item.
- Avoid jargon or terms of art, unless ubiquitous. For example, **CI** is an acceptable
substitution for **Continuous Integration**.
- Navigation links must follow the rules documented in the [data file](#data-file).
2019-02-15 15:39:39 +05:30
## How it works
2021-04-29 21:17:54 +05:30
The global nav has five levels:
2019-02-15 15:39:39 +05:30
2021-12-11 22:18:48 +05:30
- Section
2019-02-15 15:39:39 +05:30
- Category
- Doc
2021-04-29 21:17:54 +05:30
- Doc
- Doc
2019-02-15 15:39:39 +05:30
2021-12-11 22:18:48 +05:30
You can view this structure in [the navigation.yml file](https://gitlab.com/gitlab-org/gitlab-docs/-/blob/main/content/_data/navigation.yaml).
2019-02-15 15:39:39 +05:30
2021-09-30 23:02:18 +05:30
**Do not** [add items](#add-a-navigation-entry) to the global nav without
2019-02-15 15:39:39 +05:30
the consent of one of the technical writers.
## Composition
The global nav is built from two files:
- [Data](#data-file)
2019-07-07 11:18:12 +05:30
- [Layout](#layout-file-logic)
2019-02-15 15:39:39 +05:30
The data file feeds the layout with the links to the docs. The layout organizes
the data among the nav in containers properly [styled](#css-classes).
### Data file
2021-04-29 21:17:54 +05:30
The data file describes the structure of the navigation for the applicable project.
2021-09-04 01:27:46 +05:30
It is stored at <https://gitlab.com/gitlab-org/gitlab-docs/blob/main/content/_data/navigation.yaml>
2021-04-29 21:17:54 +05:30
and comprises of three main components:
2019-12-04 20:38:33 +05:30
- Sections
- Categories
- Docs
2019-02-15 15:39:39 +05:30
#### Sections
Each section represents the higher-level nav item. It's composed by
title and URL:
```yaml
sections:
- section_title: Text
section_url: 'link'
```
The section can stand alone or contain categories within.
#### Categories
Each category within a section composes the second level of the nav.
It includes the category title and link. It can stand alone in the nav or contain
a third level of sub-items.
Example of section with one stand-alone category:
```yaml
- section_title: Section title
section_url: 'section-link'
section_categories:
- category_title: Category title
category_url: 'category-link'
```
Example of section with two stand-alone categories:
```yaml
- section_title: Section title
section_url: 'section-link'
section_categories:
- category_title: Category 1 title
category_url: 'category-1-link'
- category_title: Category 2 title
category_url: 'category-2-link'
```
For clarity, **always** add a blank line between categories.
#### Docs
2021-04-29 21:17:54 +05:30
Each doc represents the third, fourth, and fifth level of nav links. They must be always
2019-02-15 15:39:39 +05:30
added within a category.
2021-04-29 21:17:54 +05:30
Example with three doc links, one at each level:
2019-02-15 15:39:39 +05:30
```yaml
- category_title: Category title
category_url: 'category-link'
docs:
- doc_title: Document title
doc_url: 'doc-link'
2021-04-29 21:17:54 +05:30
docs:
- doc_title: Document title
doc_url: 'doc-link'
docs:
- doc_title: Document title
doc_url: 'doc-link'
2019-02-15 15:39:39 +05:30
```
A category supports as many docs as necessary, but, for clarity, try to not
2021-04-29 21:17:54 +05:30
overpopulate a category. Also, do not use more than three levels of docs, it
is not supported.
2019-02-15 15:39:39 +05:30
Example with multiple docs:
```yaml
- category_title: Category title
category_url: 'category-link'
docs:
- doc_title: Document 1 title
doc_url: 'doc-1-link'
- doc_title: Document 2 title
doc_url: 'doc-2-link'
```
If you need to add a document in an external URL, add the attribute `external_url`
below the doc link:
```yaml
- doc_title: Document 2 title
doc_url: 'doc-2-link'
external_url: true
```
All nav links are clickable. If the higher-level link does not have a link
2021-02-22 17:27:13 +05:30
of its own, it must link to its first sub-item link, mimicking the navigation in GitLab.
2019-02-15 15:39:39 +05:30
This must be avoided so that we don't have duplicated links nor two `.active` links
at the same time.
Example:
```yaml
- category_title: Operations
2021-04-29 21:17:54 +05:30
category_url: 'ee/user/project/integrations/prometheus_library/'
2019-02-15 15:39:39 +05:30
# until we have a link to operations, the first doc link is
# repeated in the category link
docs:
- doc_title: Metrics
2021-04-29 21:17:54 +05:30
doc_url: 'ee/user/project/integrations/prometheus_library/'
2019-02-15 15:39:39 +05:30
```
#### Syntax
For all components (sections, categories, and docs), **respect the indentation**
and the following syntax rules.
##### Titles
- Use sentence case, capitalizing feature names.
2021-04-29 21:17:54 +05:30
- There's no need to wrap the titles, unless there's a special char in it. For example,
2019-02-15 15:39:39 +05:30
in `GitLab CI/CD`, there's a `/` present, therefore, it must be wrapped in quotes.
As convention, wrap the titles in double quotes: `category_title: "GitLab CI/CD"`.
##### URLs
2021-04-29 21:17:54 +05:30
URLs can be either relative or external, and the following apply:
2019-02-15 15:39:39 +05:30
2021-04-29 21:17:54 +05:30
- All links in the data file must end with `.html` (with the exception
of `index.html` files), and not `.md`.
- For `index.html` files, use the clean (canonical) URL: `path/to/`. For example, `https://docs.gitlab.com/ee/install/index.html` becomes `ee/install/`.
- Do not start any relative link with a forward slash `/`.
- As convention, always wrap URLs in single quotes `'url'`.
- Always use the project prefix depending on which project the link you add
lives in. To find the global nav link, from the full URL remove `https://docs.gitlab.com/`.
- If a URL links to an external URL, like the [GitLab Design System](https://design.gitlab.com),
add the attribute `external_url: true`, for example:
```yaml
- category_title: GitLab Design System
category_url: 'https://design.gitlab.com'
external_url: true
```
Examples of relative URLs:
| Full URL | Global nav URL |
| -------------------------------------------------------------- | ------------------------------------- |
| `https://docs.gitlab.com/ee/api/avatar.html` | `ee/api/avatar.html` |
| `https://docs.gitlab.com/ee/install/index.html` | `ee/install/` |
| `https://docs.gitlab.com/omnibus/settings/database.html` | `omnibus/settings/database.html` |
| `https://docs.gitlab.com/charts/installation/deployment.html` | `charts/installation/deployment.html` |
| `https://docs.gitlab.com/runner/install/docker.html` | `runner/install/docker.html` |
2019-02-15 15:39:39 +05:30
### Layout file (logic)
2021-09-04 01:27:46 +05:30
The [layout](https://gitlab.com/gitlab-org/gitlab-docs/blob/main/layouts/global_nav.html)
2019-02-15 15:39:39 +05:30
is fed by the [data file](#data-file), builds the global nav, and is rendered by the
2021-09-04 01:27:46 +05:30
[default](https://gitlab.com/gitlab-org/gitlab-docs/blob/main/layouts/default.html) layout.
2019-02-15 15:39:39 +05:30
2021-04-29 21:17:54 +05:30
The global nav contains links from all [four upstream projects](index.md#architecture).
The [global nav URL](#urls) has a different prefix depending on the documentation file you change.
2019-02-15 15:39:39 +05:30
2021-09-04 01:27:46 +05:30
| Repository | Link prefix | Final URL |
|----------------------------------------------------------------|-------------|------------------------------------|
| <https://gitlab.com/gitlab-org/gitlab/-/tree/master/doc> | `ee/` | `https://docs.gitlab.com/ee/` |
| <https://gitlab.com/gitlab-org/omnibus-gitlab/tree/master/doc> | `omnibus/` | `https://docs.gitlab.com/omnibus/` |
| <https://gitlab.com/gitlab-org/gitlab-runner/-/tree/main/docs> | `runner/` | `https://docs.gitlab.com/runner/` |
| <https://gitlab.com/charts/gitlab/tree/master/doc> | `charts/` | `https://docs.gitlab.com/charts/` |
2019-02-15 15:39:39 +05:30
### CSS classes
The nav is styled in the general `stylesheet.scss`. To change
its styles, keep them grouped for better development among the team.
The URL components have their unique styles set by the CSS classes `.level-0`,
`.level-1`, and `.level-2`. To adjust the link's font size, padding, color, etc,
use these classes. This way we guarantee that the rules for each link do not conflict
with other rules in the stylesheets.