How to see an HTML page on Github as a normal rendered HTML page to see preview in browser, without downloading?

后端 未结 10 924
情歌与酒
情歌与酒 2020-11-30 15:55

On http://github.com developer keep the HTML, CSS, JavaScript and images files of the project. How can I see the HTML output in browser?

For example this: https://gi

相关标签:
10条回答
  • 2020-11-30 16:28

    I read all the comments and thought that GitHub made it too difficult for normal user to create GitHub pages until I visited GitHub theme Page where its clearly mentioned that there is a section of "GitHub Pages" under settings Page of the concerned repo where you can choose the option "use the master branch for GitHub Pages." and voilà!!...checkout that particular repo on https://username.github.io/reponame

    screenshot to support my answer

    0 讨论(0)
  • 2020-11-30 16:28

    I have found another way:

    1. Click on the "Raw" button if you haven't already
    2. Ctrl+A, Ctrl+C
    3. Open "Developer Tools" with F12
    4. In the "Inspector" right-click on the tag and choose "Edit HTML"
    5. Ctrl+A, Ctrl+V
    6. Ctr+Return

    Tested on Firefox but it should work in other browsers too

    0 讨论(0)
  • 2020-11-30 16:35

    It's really easy to do with github pages, it's just a bit weird the first time you do it. Sorta like the first time you had to juggle 3 kittens while learning to knit. (OK, it's not all that bad)

    You need a gh-pages branch:

    Basically github.com looks for a gh-pages branch of the repository. It will serve all HTML pages it finds in here as normal HTML directly to the browser.

    How do I get this gh-pages branch?

    Easy. Just create a branch of your github repo called gh-pages. Specify --orphan when you create this branch, as you don't actually want to merge this branch back into your github branch, you just want a branch that contains your HTML resources.

    $ git checkout --orphan gh-pages
    

    What about all the other gunk in my repo, how does that fit in to it?

    Nah, you can just go ahead and delete it. And it's safe to do now, because you've been paying attention and created an orphan branch which can't be merged back into your main branch and remove all your code.

    I've created the branch, now what?

    You need to push this branch up to github.com, so that their automation can kick in and start hosting these pages for you.

    git push -u origin gh-pages
    

    But.. My HTML is still not being served!

    It takes a few minutes for github to index these branches and fire up the required infrastructure to serve up the content. Up to 10 minutes according to github.

    The steps layed out by github.com

    https://help.github.com/articles/creating-project-pages-manually

    0 讨论(0)
  • 2020-11-30 16:37

    You can use RawGit:
    https://rawgit.com/necolas/css3-social-signin-buttons/master/index.html

    It works better (at the time of this writing) than http://htmlpreview.github.com/, serving files with proper Content-Type headers. Additionally, it also provides CDN URL for use in production.

    0 讨论(0)
  • 2020-11-30 16:38

    The most comfortable way to preview HTML files on GitHub is to go to https://htmlpreview.github.io/ or just prepend it to the original URL, i.e.: https://htmlpreview.github.io/?https://github.com/bartaz/impress.js/blob/master/index.html

    0 讨论(0)
  • 2020-11-30 16:38

    You can just turn on Github Pages. ^_^

    Click on "Settings", than go to "GitHub Pages" and click on dropdown under "Source" and choose branch which you want to public (where main html file is located) aaaand vualaa. ^_^

    0 讨论(0)
提交回复
热议问题