Embedding images inside a GitHub wiki (gollum) repository?

前端 未结 15 687
时光取名叫无心
时光取名叫无心 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:27

    Figured it out.

    The url is formatted as follows

    https://raw.github.com/wiki/username/project/pathtoimage/imagename.extension

    pathtoimage is optional

    0 讨论(0)
  • 2021-01-30 01:27

    I put both images and PDFs in my wikis. I clone the wiki and add an images and a files directory, then use the following markdown to embed image links and add file links:

    Images:

    [[/images/path/to/image.ext|ALT TEXT]]
    

    The leading slash isn't necessary if your wiki pages are all at the root level, but I use subdirectories and an absolute path resolves correctly and keeps things simple.

    Files:

    [link text](files/path/to/file.ext "ALT TEXT")
    

    Note, no leading slash for the wiki files path to resolve correctly as a link in this format.

    I documented this with more detail in a GitHub gist

    0 讨论(0)
  • 2021-01-30 01:31

    The following markdown will reference an image in your GitHub repo from within your corresponding GitHub wiki

    ![My Alt Text](../blob/master/Path/ToAsset/In/Repo.png?raw=true)
    

    The above example assumes that you have the following file structure in your repo

    • Path
      • ToAssets
        • In
          • Repo.png

    For a real world example, if I wanted to reference this image in github from the corresponding wiki, I'd use this markdown

    ![Azure App Settings](../blob/master/TrelloWorld/TrelloWorld.Server/Assets/Azure_AppSettings.png?raw=true)
    

    Caveats

    1. Case matters
    2. If you are on the special Home page of the wiki, you do not need to go up a level with the ../ In my example above, the correct link would be

    For Home Page:

    ![Azure App Settings](blob/master/TrelloWorld/TrelloWorld.Server/Assets/Azure_AppSettings.png?raw=true)
    
    0 讨论(0)
提交回复
热议问题