0

Background: I'm creating a website through Shiny. I'm making use especially of the shiny.router package to enable linking between webpages and tabs in the Shiny app. The shiny.router routing logic wraps the whole website. I'm using RStudio.

Problem: I'm trying to add a link to a website external to my Shiny app, using tags$a(). When I try clicking the link, I get a "not found" error. I've found that this is because it appends "./#!/" to the link I've provided. For example, instead of going to "www.google.com" tries to go to "./#!/www.google.com" Since this processing happens when the R code is converted to html, I'm unsure where to intervene and remove the appended portion.

Possible causes: I have a few clues as to what's happening, I think it could be related to the router package I'm using or the fact that I run my app with shinyAppDir("."). I've had to run my app with shinyAppDir(".") because it has a lot of trouble accessing the images I have stored in my www folder without it. I did try commenting the shinyAppDir(".") portion out and running the app without it, however, the links still don't work and the photos and other media files I have don't appear consistently. Please let me know if there's a better solution to the photo issue. I'm not sure what's causing it as certain mediafiles are accessed while others aren't, despite being located in the same www folder and being of the same file type and having similar file sizes. Rstudio also seems to 'see' these files: they appear in the working directory panel. Could this be related to the issue I'm having with routing?

Is there some kind of other rShiny tag or function that allows for specifying an external link? Do you know what might be causing Shiny to append "./#!/" to the href I'm providing?

1
  • A possible workaround not a solution, but some googling suggests having links open in a new tab (include target="_blank" in the link) seems to help. Commented Oct 13, 2023 at 14:53

1 Answer 1

0

You have to write the full address, with https://:

tags$a(href = "https://www.google.com/", "GOOGLE")

or, to open the link in a new window:

tags$a(href = "https://www.google.com/", target = "_blank", "GOOGLE")

The ./#!/ is caused by shiny.router. This is a base element I think.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.