1. Create a new HTML file. For example, create a file called test.html
:
<p>A new HTML file</p>
2. Upload this file to the GitHub repository:
3. Update the index.html
of your website and add a link:
<a href="https://[your_github_username].github.io/[repository_name]/test.html">Link</a>
You can also use the following code to link to the new HTML file:
<a href="test.html">Link</a>
The href attribute above (href="test.html"
) uses a filepath. It follows the same rules as loading CSS files and images:
href="test.html"
=> links to a file calledtest.html
beside the current HTML file that's open in the browser.href="folder1/test.html"
=> looks insidefolder1
for a file calledtest.html
and links to that file.
The 2nd option, using a filepath, is preferred since it's easier to type and it won't break if the first part of the URL (https://[your_github_username].github.io/[repository_name]/
) changes.