Skip to content

Commit

Permalink
Make logo location configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
bdfinst committed Jul 7, 2023
1 parent 8bd855d commit dbe7a5b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
8 changes: 6 additions & 2 deletions layouts/partials/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
{{- /**/ -}}
<span class="navbar-brand__logo navbar-logo">
{{- if ne .Site.Params.ui.navbar_logo false -}}
{{ with resources.Get "icons/logo.svg" -}}
{{ $logo := "icons/logo.svg" }}
{{ with .Site.Params.ui.navbar_logo }}
{{ $logo = . }}
{{ end }}
{{ with resources.Get $logo -}}
{{ ( . | minify).Content | safeHTML -}}
{{ end -}}
{{ end -}}
Expand Down Expand Up @@ -63,4 +67,4 @@
{{ partial "search-input.html" . }}
</div>
</div>
</nav>
</nav>
21 changes: 19 additions & 2 deletions userguide/content/en/docs/adding-content/iconsimages.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ description: Add and customize logos, icons, and images in your project.
## Add your logo

By default, Docsy shows a site logo at the start of the navbar, that is, at the
extreme left. Place your project's SVG logo in `assets/icons/logo.svg`. This
overrides the default Docsy logo in the theme.
extreme left. You may either place your project's SVG logo in `assets/icons/logo.svg` or define a custom path under the
`assets/` folder. This overrides the default Docsy logo in the theme.

If you don't want a logo to appear in the navbar, then set `navbar_logo` to
`false` in your project's config:
Expand All @@ -29,6 +29,23 @@ navbar_logo: false
{{< /tab >}}
{{< /tabpane >}}

Alternatively, if you want to override the default `assets/icons/logo.svg` location, then set `params.ui.navbar_logo` to the desired path in your project's config:

{{< tabpane >}}
{{< tab header="Configuration file:" disabled=true />}}
{{< tab header="hugo.toml" lang="toml" >}}
navbar_logo = "/img/myLogo.svg"
{{< /tab >}}
{{< tab header="hugo.yaml" lang="yaml" >}}
navbar_logo: "/img/myLogo.svg"
{{< /tab >}}
{{< tab header="hugo.json" lang="json" >}}
{
"navbar_logo": "/img/myLogo.svg"
}
{{< /tab >}}
{{< /tabpane >}}

For information about styling your logo, see [Styling your project logo and
name][].

Expand Down

0 comments on commit dbe7a5b

Please sign in to comment.