161

How is this done? I'd like to have the link be in a markdown cell.

abcd
  • 10,215
  • 15
  • 51
  • 85

7 Answers7

293

For visual learners:

[blue_text](url_here)
abcd
  • 10,215
  • 15
  • 51
  • 85
R.Sanchez
  • 3,366
  • 1
  • 13
  • 6
  • 4
    For 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
  • 6
    it is important that you left no blank space between ] and ( in [blue_text](url_here) – Kardi Teknomo Dec 07 '18 at 05:11
  • 2
    Its 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
43

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>"""))
linqu
  • 11,320
  • 8
  • 55
  • 67
13

Just another tip, using magic expression.

%%html
<a href="your_url_here">Showing Text</a>

Improved. Thanks to the comment of calocedrus.

Huang Baochen
  • 141
  • 1
  • 4
7

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

hjpotter92
  • 78,589
  • 36
  • 144
  • 183
jasonMmedina
  • 81
  • 1
  • 6
2

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.

ackerleytng
  • 416
  • 6
  • 17
0

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:

Output from Markdown cell in Notebook

Gray
  • 1,164
  • 1
  • 9
  • 23
-2
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")
Andy Preston
  • 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