如何将 URL 链接添加到顶部导航栏

lc2*_*c23 3 html r r-markdown flexdashboard

我尝试在此处和其他论坛中找到解决方案,但一无所获。

我正在使用 flexdashboard 创建一个网站(HTML 文件)。它有几个页面,每个页面都可以通过顶部的导航栏访问。就像是:

Home
=======================================================================

Row
-----------------------------------------------------------------------

### Cover Picture {.no-title} ![](picture0.jpg)

Page 1
=======================================================================

Row
-----------------------------------------------------------------------

### Picture 1 {.no-title} ![](picture1.jpg)

Row
-----------------------------------------------------------------------

### Picture 2 {.no-title} ![](picture2.jpg)
Run Code Online (Sandbox Code Playgroud)

我想在导航栏中添加一个指向外部网站的链接,比如谷歌。我尝试简单地添加如下内容:

[www.google.com]
=======================================================================
Run Code Online (Sandbox Code Playgroud)

但是,当我点击它时,它会转到我的 html 中一个名为 [www.google.com] 的空白页面。为了实际转到 Google 的网页,我必须右键单击该链接并单击“在新选项卡中打开”。

如果我尝试使用下拉导航栏菜单,也会发生同样的情况:

[www.google.com] {data-navmenu="External URLs"}
=======================================================================

[www.bing.com] {data-navmenu="External URLs"}
=======================================================================
Run Code Online (Sandbox Code Playgroud)

我还尝试在链接之前向页面插入一个名称:

Google's Page [www.google.com] 
=======================================================================
Run Code Online (Sandbox Code Playgroud)

或者甚至为链接使用自定义名称:

[www.google.com](Google) 
=======================================================================
Run Code Online (Sandbox Code Playgroud)

我理解这样的基本原理:如果我创建了一个名为 [www.google.com] 的空白页面,那么如果我在导航栏中单击它,它就会转到我的 HTML 中的那个空白页面。但是有什么方法可以让它理解实际上我不希望那个空白页面存在,我只希望在我的导航栏中使用外部链接?

我希望链接的行为就像我写的那样:

### [www.google.com]
Run Code Online (Sandbox Code Playgroud)

当我点击它时,它会直接进入 Google 的网站。

任何帮助是极大的赞赏。

Jam*_*ack 5

您可以使用添加到右侧的链接,

---
title: "My dashboard"
output:
  flexdashboard::flex_dashboard:
    navbar:
      - { icon: "fa-question-circle", href: "https://google.com", align: right }
---
Run Code Online (Sandbox Code Playgroud)

在您的 YAML 中 - 这将放置一个问号图标作为链接。有关更多选项,请查看在 R 中navbar键入?flexdashboard::flex_dashboard控制台后调用的部分。