Embedding images inside a GitHub wiki (gollum) repository?

前端 未结 15 780
时光取名叫无心
时光取名叫无心 2021-01-30 00:43

The Github wikis are backed by a separate git repository then the main project repository.

This post by the Github team makes it sound like you should be able to link to

15条回答
  •  南笙
    南笙 (楼主)
    2021-01-30 01:23

    None of answers seem to work when adding an image in readme.md. I've got a solution though:

    If the URL of the image is:

    https://github.com/Username/Repository-Name/blob/master/Directory-Inside-Repository/image.png
    

    Replacing blob with raw gives you the URL of the raw image:

    https://github.com/Username/Repository-Name/raw/master/Directory-Inside-Repository/image.png
    

    Now, you'd embed the image using normal markdown:

    ![Image Alt](https://github.com/Username/Repository-Name/raw/master/Directory-Inside-Repository/image.png)
    

    UPDATE: As of now, GitHub also serves raw images from a different sub-domain raw.github.com. So, you can also use:

    https://raw.github.com/Username/Repository-Name/master/Directory-Inside-Repository/image.png
    

    EXAMPLE: https://raw.github.com/Automattic/liveblog/master/screenshot-1.png

提交回复
热议问题