In GitHub, adding images to your README.md file can enhance the visual appeal of your project documentation. Follow these steps:
-
Upload Images to Your GitHub Repository First, upload your image file to your GitHub repository. You can place it anywhere in the repository, but it's common to store images in a folder named
imagesorassetsfor better organization. -
Get the Image URL After uploading the image, click on the image file to open it in a new page. Then, right-click the image and select 'Copy Image Address' to obtain the URL.
-
Edit the README.md File In your
README.mdfile, you can use Markdown syntax to insert images. The basic Markdown format is as follows:markdownHere, "alt text" is the alternative text displayed when the image cannot be shown, and "URL" is the image address you copied in the previous step.
Example:
markdownIf you want the image to link to a URL (e.g., opening your website when clicking the image), wrap the image Markdown in a link Markdown:
markdown[](https://yourwebsite.com) -
Adjust Image Size and Alignment Markdown itself does not support direct image resizing, but you can use HTML tags to achieve this:
markdown<img src="https://github.com/username/repository/blob/main/images/logo.png" alt="Logo" width="200">Here,
width="200"sets the image width to 200 pixels. You can also use theheightattribute to set the height.Aligning images typically requires using HTML
<p>or<div>tags with thealignattribute:markdown<p align="center"> <img src="https://github.com/username/repository/blob/main/images/logo.png" alt="Logo" width="200"> </p> -
Commit the Changes After completing the edits, commit the changes to your
README.mdfile. This will display the image on your project's homepage.
Follow these steps to add images to your README.md file and ensure the image links are publicly accessible so that anyone viewing your project can see the images.