Pkgdown: Support for displaying GitLab icon in web page

Created on 24 Jun 2020  路  6Comments  路  Source: r-lib/pkgdown

When my package is hosted on GitLab, I found that the icon on the generated web page was GitHub, but the connection was normal and I need to make some adjustments manually in docs/index.html.

<span class="fab fa fab fa-gitlab fa-lg"></span>

feature help wanted navbar

Most helpful comment

You can configure this in your _pkgdown.yml. Here's a quick example modifying the navbar configuration demonstrated in the package documentation at YAML config - navbar.

Instead of github, you can create a gitlab component that uses the GitLab Font Awesome icon and points to your GitLab URL.

navbar:
  structure:
    left:  [home, intro, reference, articles, tutorials, news]
    right: [gitlab]
  components:
    gitlab:
      icon: fab fa-gitlab fa-lg
      href: https://gitlab.com/username/project

All 6 comments

I just ran into this issue too. Is there a way to get the right icon without having to manually modify the html?

You can configure this in your _pkgdown.yml. Here's a quick example modifying the navbar configuration demonstrated in the package documentation at YAML config - navbar.

Instead of github, you can create a gitlab component that uses the GitLab Font Awesome icon and points to your GitLab URL.

navbar:
  structure:
    left:  [home, intro, reference, articles, tutorials, news]
    right: [gitlab]
  components:
    gitlab:
      icon: fab fa-gitlab fa-lg
      href: https://gitlab.com/username/project

You can configure this in your _pkgdown.yml. Here's a quick example modifying the navbar configuration demonstrated in the package documentation at YAML config - navbar.

Instead of github, you can create a gitlab component that uses the GitLab Font Awesome icon and points to your GitLab URL.

navbar:
  structure:
    left:  [home, intro, reference, articles, tutorials, news]
    right: [gitlab]
  components:
    gitlab:
      icon: fab fa-gitlab fa-lg
      href: https://gitlab.com/username/project

That's a good idea, but I still think it's complicated.

Thanks, @gadenbuie! This solution works, but if one has URL set in the DESCRIPTION file (or repo: url: ... in _pkgdown.yml), the Github icon is still displayed, now on the left side. Is there a way to get rid of it without removing the URL definition (which is useful to have for other parts of the webpage generated by pkgdown).

I can reproduce this, too. Essentially, if repo$url$home is set in the _pkgdown.yml, then a github navbar component is added (here in navbar_component()).

With the following _pkgdown.yml a GitHub icon will appear on the left navbar linking to repo$url$home.

repo:
  url:
    home: https://gitlab.com/username/project

navbar:
  structure:
    left:  [home, intro, reference, articles, tutorials, news]
    right: [gitlab]
  components:
    gitlab:
      icon: fab fa-gitlab fa-lg
      href: https://gitlab.com/username/project

You can actually suppress the extra icon by changing the name of the gitlab component to github, although I don't think this is documented and maybe the maintainers will want to change this.

repo:
  url:
    home: https://gitlab.com/username/project

navbar:
  structure:
    left:  [home, intro, reference, articles, tutorials, news]
    right: [github]
  components:
    github:
      icon: fab fa-gitlab fa-lg
      href: https://gitlab.com/username/project

I don't use GitLab, so if folks want this in pkgdown, someone is going to have to propose a PR.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ms609 picture ms609  路  6Comments

jeffwong picture jeffwong  路  9Comments

mjsteinbaugh picture mjsteinbaugh  路  7Comments

Fazendaaa picture Fazendaaa  路  9Comments

maelle picture maelle  路  6Comments