How is this done? I'd like to have the link be in a markdown cell.
7 Answers
-
4For me, certain special characters like "(" or ")" may brake the file/page path and lead to the link not working. I fixed it by replacing them with the code equivalents found here and then everything worked. http://www.theukwebdesigncompany.com/articles/entity-escape-characters.php – Afflatus Feb 13 '17 at 15:42
-
6it is important that you left no blank space between ] and ( in [blue_text](url_here) – Kardi Teknomo Dec 07 '18 at 05:11
-
2Its wierd, any of these options doesnt work, if the text in Markdown cell Starts with a tab. ie if there is more than 4 spaces in the starting of the cell, then it simply does'nt work – sjd Jul 17 '20 at 06:21
In case it is not a markdown cell, that is with what I went:
from IPython.core.display import display, HTML
display(HTML("""<a href="https://google.at">text</a>"""))

- 11,320
- 8
- 55
- 67
-
Is there any way I can print more text in the same line as this code? So it will display a hyperlink followed by some text? – Sameh Oct 25 '19 at 12:58
-
1
-
Thanks. How can I do something like this: name = 'MyName' display(HTML("""text {name}""")) – Sameh Oct 29 '19 at 18:28
-
-
Have you tested out? It doesn't work at my end. It returns an error (KeyError: 'name') – Sameh Nov 03 '19 at 01:09
-
@Sameh that's true, there is a syntax error, it should be: name = 'Sameh'; display(HTML("""text {}""".format(name))) – linqu Nov 04 '19 at 07:02
-
1for those seeking for displaying the page in new tab, here is a sample: display(HTML("""text""")) – Kang Aug 20 '21 at 03:47
Just another tip, using magic expression.
%%html
<a href="your_url_here">Showing Text</a>
Improved. Thanks to the comment of calocedrus.

- 141
- 1
- 4
-
1There's no space after the `%%`: `%%html`. And you could add the visible hyperlinked text just before ``, after the closing `>`: `clickable text`. Still, +1. – calocedrus Feb 26 '19 at 06:22
-
-
%%html has to be the first thing in the cell, you cannot have any text before – elomage Dec 06 '19 at 08:19
Here is the code I use in my python notebook when I want to insert a link to a webpage inside a markdown cell (in a python notebook).
[Clickable_visible_hyperlink](Hidden_landing_URL)
--note Here is the clickable hyperlink, you can change the value

- 78,589
- 36
- 144
- 183

- 81
- 1
- 6
-
1
-
1Hey good catch! This answer includes function descriptions of how links perform and what they do. – jasonMmedina May 17 '18 at 16:50
-
hello. the Hidden_landing_URL in my case can only be known at runtime, how can I put a dynamic url here? – Kang Aug 20 '21 at 02:54
This might help too, if you're looking to display a link programmatically.
from IPython.display import display, Markdown
display(Markdown("[google](https://www.google.com)"))
I also tried
display(HTML("""<a href="https://www.google.com>google</a>"""))
But somehow I was getting the object printed out, instead of the rendered version.

- 416
- 6
- 17
For programming in R, do the following when using Jupyter Notebook or Jupyter Lab - (using the R kernel). These steps will display a web link and an image in a Notebook markdown cell. The following shows a real-life example of some study notes using Jupyter Lab and R.
First open a markdown cell in Jupyter - can be a new markdown cell or an existing markdown cell. Then copy and paste the actual web address into a markdown cell. This will provide an active link to that website from the Notebook.
Step 2, from that website, copy the image that you want to view in the Notebook. This image should be in a standard image format (.png, .jpg, etc ). Paste this image into the same folder on the computer where the Jupyter notebook file is located. Note: if the image is later deemed too large or small, then resize using any graphics software available - and then save the changed image into this same folder. Note: it is important to know the name of this image file.
Next, paste the name of the image file between the quotation marks in the following code: . If this file in not within your existing jupyter notebook working directory, then a path to the image file will need to be placed inside the quotation marks.
Step 3, also included is an example of the line of code (also used in Notebook markdown cell) to create colored text in markdown cells. In this line of code, the double ## character results in the second largest font being used in Jupyter. Smaller text using more of these characters - with #### being the smallest. One # results in the largest font output.
Last, be sure to close and run the markdown cell to view the output. The code for the markdown cell follows, and further below shows the output from the Notebook.
Code in Markdown cell:
"https://www.tensorflow.org/images/colab_logo_32px.png" # link to website
<img src="tidyflow.png" /> # The image file (This path is the same folder as Notebook file)
## <font color = cyan> Some Colored Text in Notebook Markdown Cell </font> # colored text
Output:

- 1,164
- 1
- 9
- 23
import random
name = input("what is your name ?")
print("Good Luck !", name)
words = ['Rainbow','Computer','Science','Programming',
'Python','C++']
word = random.choice(words)
print("Guess The Characters")
guesses = ''
turns = 12
while turns > 0:
failed = 0
for char in word:
if char in guesses:
print(char, end=" ")
else:
print("_")
failed += 1
if failed == 0:
print("You Win")
guess = input("guess a character:")
guesses += guess
if guess not in word:
turns -= 1
print("wrong")
print("You Have", +turns, 'more guesses')
if turns == 0:
print("You Loose")

- 779
- 4
- 9
- 23
-
Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 17 '23 at 17:14