Skip to content

Commit f425127

Browse files
committed
Navbar-brand: define classes for the logo and name
1 parent 8d6f811 commit f425127

File tree

4 files changed

+42
-41
lines changed

4 files changed

+42
-41
lines changed

assets/scss/_nav.scss

+2-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@
4141
text-transform: none;
4242
text-align: middle;
4343

44-
.nav-link {
45-
display: inline-block;
46-
margin-right: -30px;
44+
&__name {
45+
font-weight: $font-weight-bold;
4746
}
4847

4948
svg {

layouts/partials/navbar.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
(not .Site.Params.ui.navbar_translucent_over_cover_disable)
44
-}}
55

6-
<nav
7-
class="js-navbar-scroll navbar navbar-expand navbar-dark {{ if $cover }}td-navbar-cover{{ end }} flex-column flex-md-row td-navbar">
6+
<nav class="js-navbar-scroll navbar navbar-expand navbar-dark
7+
{{- if $cover }} td-navbar-cover {{- end }} flex-column flex-md-row td-navbar">
88
<a class="navbar-brand" href="{{ .Site.Home.RelPermalink }}">
99
{{- /**/ -}}
10-
<span class="navbar-logo">
10+
<span class="navbar-brand__logo navbar-logo">
1111
{{- if .Site.Params.ui.navbar_logo -}}
1212
{{ with resources.Get "icons/logo.svg" -}}
1313
{{ ( . | minify).Content | safeHTML -}}
1414
{{ end -}}
1515
{{ end -}}
1616
</span>
1717
{{- /**/ -}}
18-
<span class="font-weight-bold">
18+
<span class="navbar-brand__name">
1919
{{- .Site.Title -}}
2020
</span>
2121
{{- /**/ -}}

userguide/content/en/docs/adding-content/iconsimages.md

+9-34
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
2-
title: "Logos and Images"
3-
linkTitle: "Logos and Images"
2+
title: Logos and Images
43
date: 2017-01-05
54
weight: 6
6-
description: >
7-
Add and customize logos, icons, and images in your project.
5+
description: Add and customize logos, icons, and images in your project.
86
---
97

108
## Add your logo
119

12-
Add your project logo as `assets/icons/logo.svg` in your project. This overrides the default Docsy logo in the theme. If you don't want a project logo, set `navbar_logo` to `false` (or delete the variable) in your `config.toml`/`config.yaml`/`config.json`:
10+
Place your project logo in `assets/icons/logo.svg`. This overrides the default
11+
Docsy logo in the theme. If you don't want a project logo, set `navbar_logo` to
12+
`false` in your project's config:
1313

1414
{{< tabpane persistLang=false >}}
1515
{{< tab header="Configuration file:" disabled=true />}}
@@ -26,35 +26,10 @@ navbar_logo: false
2626
{{< /tab >}}
2727
{{< /tabpane >}}
2828

29-
If you decide at a later stage that you'd like to add a logo to your navbar, you can set the parameter to `true`:
29+
For information about styling your logo, see [Styling your brand logo and
30+
name][]
3031

31-
{{< tabpane persistLang=false >}}
32-
{{< tab header="config.toml" lang="toml" >}}
33-
navbar_logo = true
34-
{{< /tab >}}
35-
{{< tab header="config.yaml" lang="yaml" >}}
36-
navbar_logo: true
37-
{{< /tab >}}
38-
{{< tab header="config.json" lang="json" >}}
39-
{
40-
"navbar_logo": true
41-
}
42-
{{< /tab >}}
43-
{{< /tabpane >}}
44-
45-
{{% alert title="Tip" %}}
46-
Your logo is included in the default Docsy navbar as an inline SVG with the following CSS styling (from [`_nav.scss`](https://github.com/google/docsy/blob/main/assets/scss/_nav.scss)):
47-
48-
```
49-
svg {
50-
display: inline-block;
51-
margin: 0 10px;
52-
height: 30px;
53-
}
54-
```
55-
56-
To ensure your logo displays correctly, you may want to resize it, ensure it doesn't have height and width attributes so that its size is fully responsive, or override the default styling with your own CSS.
57-
{{% /alert %}}
32+
[Styling your brand logo and name]: /docs/adding-content/lookandfeel/#styling-your-brand-logo-and-name
5833

5934
## Add your favicons
6035

@@ -70,7 +45,7 @@ If you have special favicon requirements, you can create your own `layouts/parti
7045

7146
Docsy's [`blocks/cover` shortcode](/docs/adding-content/shortcodes/#blockscover) make it easy to add large cover images to your landing pages. The shortcode looks for an image with the word "background" in the name inside the landing page's [Page Bundle](https://gohugo.io/content-management/page-bundles/) - so, for example, if you've copied the example site, the landing page image in `content/en/_index.html` is `content/en/featured-background.jpg`.
7247

73-
You specify the preferred display height of a cover block container (and hence its image) using the block's `height` parameter. For a full viewport height, use `full`:
48+
You specify the preferred display height of a cover block container (and hence its image) using the block's `height` parameter. For a full viewport height, use `full`:
7449

7550
```html
7651
{{</* blocks/cover title="Welcome to the Docsy Example Project!" image_anchor="top" height="full" color="orange" */>}}

userguide/content/en/docs/adding-content/lookandfeel.md

+27
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: Look and Feel
33
date: 2017-01-05
44
weight: 2
55
description: Customize colors, fonts, code highlighting, and more for your site.
6+
spelling: cSpell:ignore wordmark docsy
67
---
78

89
By default, a site using Docsy has the theme's default fonts, colors, and general look and feel. However, if you want your own color scheme (and you probably will!) you can very easily override the theme defaults with your own project-specific values - Hugo will look in your project files first when looking for information to build your site. And because Docsy uses Bootstrap 4 and SCSS for styling, you can override just single values (such as project colors and fonts) in its special SCSS project variables file, or do more serious customization by creating your own styles.
@@ -213,7 +214,33 @@ site's [configuration file][].
213214
[configuration file]: https://gohugo.io/getting-started/configuration/#configuration-file
214215
[primary color]: #site-colors
215216

217+
### Styling your brand logo and name
216218

219+
The default Docsy navbar (`.td-navbar`) contains your navbar-brand, consisting
220+
of the following:
221+
222+
1. [Your logo][], which is included in the navbar as an inline SVG, styled by
223+
`.td-navbar .navbar-brand svg`. For the style details, see [_nav.scss][].
224+
225+
To ensure your logo displays correctly, you may want to resize it and ensure
226+
that it doesn't have height and width attributes so that its size is fully
227+
responsive. [Override the default styling][project-styles] of `.td-navbar
228+
.navbar-brand svg` or (equivalently) `.td-navbar .navbar-brand__logo` as
229+
needed.
230+
2. Your brand name, which is the site `title`. If you don't want the brand name
231+
to show (for example, because your logo is or contains a [wordmark][]), then
232+
add the following custom styling to your [project's styles][project-styles]:
233+
234+
```css
235+
.td-navbar .navbar-brand__name {
236+
display: none;
237+
}
238+
```
239+
240+
[_nav.scss]: https://github.com/google/docsy/blob/main/assets/scss/_nav.scss
241+
[project-styles]: /docs/adding-content/lookandfeel/#project-style-files
242+
[wordmark]: https://en.wikipedia.org/wiki/Wordmark
243+
[your logo]: /docs/adding-content/iconsimages/#add-your-logo
217244

218245
## Customizing templates
219246

0 commit comments

Comments
 (0)