Yogi
Yogi

Reputation: 19

How to add an external link - Ruby on Rails

I am trying to link an external link to the code. Currently I have the following:

   <div class="col-md-4">
     <div class="thumbnail">
     <a href="www.google.com" target="_blank">
     <img src="/assets/laptop.jpg" alt="Fjords" style="width:100%">
     <div class="caption">
     <p>How to set up emails</p>
     </div>
     </a>
  </div>
  </div>

I am getting an error telling me "No route matches [GET] "/www.google.com". However, I only want to click onto the picture and for the page to go to google.

Upvotes: 0

Views: 158

Answers (2)

infused
infused

Reputation: 24337

You need to specify the protocol too (https:)

<a href="https://www.google.com" target="_blank">

Relative URL (URL with no protocol specified) are used to reference links on the same site. You need to use the Absolute URL (with protocol and other information like protocol, domain name) to refer to an external site.

Upvotes: 4

user8927599
user8927599

Reputation:

Relative URL are used to reference links on the same site. You need to use the Absolute URL to refer to an external site.

You can reference external links without protocol by:

<a href="//www.google.com" target="_blank"> 

Or use:

<a href="https://www.google.com" target="_blank">

Upvotes: 0

Related Questions