How to add images to README.md on GitHub?

 

You can add images to a README.md file on GitHub using Markdown syntax and providing the URL to the image. Here's an example of how to do it:

Let's say you have an image named example.png in your repository's root directory, and you want to include it in your README.md:

  1. Upload the Image: Make sure the image example.png is in the same directory as your README.md file or provide the correct relative path if it's in a different directory.

  2. Insert the Image in README.md: Use Markdown syntax to insert the image into your README.md. The basic syntax for adding an image is: ![Alt Text](Image URL).

    markdown
  1. ![Example Image](example.png)

    In this example, Alt Text is a description of the image that appears if the image cannot be loaded, and Image URL is the URL or path to the image.

  2. Commit and Push: After adding the image link to your README.md, commit your changes and push them to your GitHub repository.

  3. View the Image on GitHub: Once your changes are pushed, open your repository's README.md file on GitHub. You should see the image displayed in your README.

Note that you can use both absolute URLs (e.g., hosted on the web) and relative paths (within the repository). Using relative paths is recommended to ensure the images are always available, even if the repository is cloned or downloaded.

Remember to check the image's formatting and display on both your local environment and GitHub to ensure everything is working as expected.

Comments