0

Let's say I have some html files "index.html", "learn.html", etc in username.github.io and when I click "index.html" they all are rendered as html.

Now, I have another html in "mythmls/myhtml.html" in the same repository. How to include this html in "learn.html" so that when I click the link it will RENDER the html of "myhthml.html" file not just show the SOURCE CODE?

Attempt1
Inside the username.github.io/learn.html I added the following:

                    <h2><a name="Learn">Leetcode</h2>
                    <ul>
                      <li><a href="https://raw.githubusercontent.com/bhishanpdl/bhishanpdl.github.io/master/leetcode/lc_977.html">lc977</a></li>
                    </ul>
                    <br>

When I click this link, it gives me raw html source code, not the rendered version of HTML.

Attempt2

               <div>
                <iframe src="lc_955.html" name="targetframe" allowTransparency="true" scrolling="yes" frameborder="0" >
                </iframe>
                </div>

This gives empty box with 404 ERRROR at the top right corner.

I am very new to HTML and this is the file I am trying to edit.

Do we have to create a new tab for each new html files?

Can we create just one tab and put some links there so that when we click that link it will RENDER the html (not show the SOURCE CODE) ?

1 Answer 1

2

The link you gave us points to a page on GitHub which shows a preview of source code, not to the actual HTML file. The link to the raw file is on raw.githubusercontent.com - in your case here. I got that link by clicking the Raw button on the GitHub page.

However, GitHub serves this page with a text/plain Content-Type header, meaning the browser will not understand this as HTML if you link to it. GitHub does this specifically to prevent this kind of abuse - you're not supposed to use GitHub to point to files in other repositories like that, for too many reasons to start listing them (security and efficiency issues for a start).

Since you are not the owner of this repository, you cannot know that it will not change, therefore the only way you can safely serve its files as HTML is to copy them to your own repository. However, I see no license file on that repository, meaning you are not allowed to copy its content without authorization.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a lot for the suggestions, both repository are mine, I like the idea of adding LICENCE file to my repositories. I also have the same file in username.github.io repository, I will give another shot to make it work.
Oh, well in that case you could also add a gh-pages branch to the other repository and have it actually served as a website too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.