How to link to external site from NextJS - next.js

I feel like this is quite a basic question, but...how?
Googled various forms of this question and couldn't find a clear answer. I'm using NextJS and just want the user to click a button and be taken to a completely different site.

Have a link styled like a button and put in the href that you want the user to visit. Something like this if you're using tailwind:
<Link href="https://www.google.com/">
<a className="p-2 lg:px-4 mx-2 text-black text-center border border-solid border-black rounded ">Go to google</a>
</Link>
You can also add target='_blank' to the anchor if you want the URL to open in a new tab.

You can use the following code snippet. We passHref in Link to pass the href to anchor tag so that the SEO will not hurt. Use target='_blank' in the anchor tag to open the external link in the new tab.
<Link href="https://www.google.com/" passHref>
<a target='_blank' >Go to google</a>
</Link>

Just add rel="noopener" inside the anchor tag bro.
If doesn't works then try adding rel="noopener noreferrer".
<Link href="https://www.google.com/" passHref>
<a target='_blank' rel="noopener">Go to google</a>
</Link>

import Link from "next/link"; //import this
<Link href="/"> //wrap a tag with Link
<a>Home</a>
</Link>
<Link href="https://nextjs.org"> //external page
<a>Next.js</a>
</Link>

Related

Next.js <a> tag vs passHref

Can someone explain to me the difference between using passHref and using an anchor tag when setting up links between pages in Next.js?
E.g. what is the difference between:
<Link href={`/posts/${post.id}`} passHref>
<h2>
{post.id} {post.title}
</h2>
</Link>
and
<Link href={`/posts/${post.id}`}>
<a>
{post.id} {post.title}
</a>
</Link>
I tried reading about it in the documentation but could not seem to find the answer.
From the docs:
passHref - Forces Link to send the href property to its child. Defaults to false
When using <Link> wrapping a custom component and not an anchor tag, the <Link> tag must have the passHref attribute. Without this, the tag will not have the href attribute, which hurts your site's accessibility and might affect SEO.
Source

Placing Link Text Within a Button in Angular App

I have an href link that triggers a download located within a button in my Angular component HTML. I can see both the button and the highlighted text link in my browser. However, when I click the link, nothing happens - in terms of triggering the download. This is what I have:
<button class="email-prompt-button" md-button>
<a [href]="fileUrl" download="file.txt" class="btn-link">Download File</a>
</button>
Now, if I remove the button, and just have the a tag, it works:
<a [href]="fileUrl" download="file.txt" class="btn-link">Download File</a>
How can I get this to works as link text within a button?
Why don't you shape your anchor tag shapes to look like a button by applying custom css
or
If you're using Bootstrap you can apply below classes:
btn btn-primary
Just like
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<a [href]="fileUrl" download="file.txt" class="btn btn-primary btn-link">Download File</a>

How to hide urls of hyperlink in outlook?

I am sending mail through my emailer and in my email i am sending an image with the background hyperlink, the email showing normal but in system configured outlook showing the link of URL of the hyperlink.
Please visit below mention URL
https://prnt.sc/itb5wq
I am trying to hide URL using placing span or p tag before hyperlink.
Source code:
<span style="color:#ffffff;">Text Something</span>
<a href="#" id="m-banner-anchor">
I tried this code and worked for me perfectly:
<span style="opacity:0"><font color="white" size="1">Text Here</font></span><br><br>
<a href="#" id="m-banner-anchor">
<img src="images/cengage_promo_header.jpg" id="m-banner-image" height="184" width="755" />
</a>
Your approach was not that bad, here's the correct syntax for a HTML hyperlink:
I am a link and you can't see my destination!
Or in your case:
<span style="color: #fffff">Text Something</span>
Put your span in your hyperlink ...
<span style="color:#ffffff;">Please Visit</span>

Image Could not be loaded - Wordpress issue

I am having issue on my wordpress website. Where I have gallery plugin and the images in that gallery showing this error message when you click on the image. In past those used to pop up when you click on it. But currently it show this error message. I think there is some js conflict please help me here. screenshot- here
webpage - http://www.marvelrealtors.com/residential-properties/izara/
image url is missing in anchor tag. please check.
<a href="#" class="poppup">
<img src="http://www.marvelrealtors.com/wp-content/uploads/2015/05/Izara-Dining-Room.jpg" title="Dining" alt="Dining" data-lazy-loaded="true" style="display: inline;"><noscript><img title="Dining" src="http://www.marvelrealtors.com/wp-content/uploads/2015/05/Izara-Dining-Room.jpg" alt="Dining"/></noscript>
</a>
Working script:
<a class="image-popup-no-margins boxed_shadow" href="http://www.marvelrealtors.com/wp-content/uploads/2015/06/Izara-site-plan.jpg" target="_self">
<img src="http://www.marvelrealtors.com/wp-content/uploads/2015/06/Izara-site-plan.jpg" class=" vc_box_border_grey attachment-full" alt="layout" data-lazy-loaded="true" style="display: inline;"><noscript><img src="http://www.marvelrealtors.com/wp-content/uploads/2015/06/Izara-site-plan.jpg" class=" vc_box_border_grey attachment-full" alt="layout" /></noscript>
</a>
The problem comes from file names, no accent, space or special character and it will work.

apply CSS only to a specific cshtml block

I am adding bootstrap.css to design some elements of a certain div without messing with the rest of the elements.
Example:
...code here...
<div class="btn-group">
<button class="btn dropdown-toggle" data-toggle="dropdown">
</div>
...some more code here...
Importing bootstrap.css:
<link href="/css/bootstrap.css" rel="stylesheet" type="text/css" />
But when I run my code, the bootstrap.css messes with the rest of the elements. How can I import bootstrap.css that it will only apply on btn-group class?
You need to customize Bootstrap before downloading to include the required parts only
go to http://getbootstrap.com/customize/
click "Toggle all" to uncheck all components check required components only e.g. 'Buttons'
go all the way down and click 'Compile and download'

Resources