2

The location at which my site ACTUALLY works: https://username.github.io/html/

The location at which I want my site to ACTUALLY work: http://username.github.io

Initially, I had my index.html directly in my repository, but then I moved it into an html folder with all my other html files for organization. How do I make it so it works in the following manner:

<head>
<title> NAME </title>
<meta name="viewport" content="width=device-width">
<link rel="shortcut icon" type="image/ico" href="/favicon.ico">
<link rel="stylesheet" href="../css/index.css">
</head>

<section id="Site">
<h3>
<a href="../html/">FIRST LAST </a>
</h3>
</section>

The location at which I want my site to ACTUALLY work: http://username.github.io

Thanks

  • You don't. You don't get access to vanity urls in that way on Github - set up a dedicated branch for your web content, with your index.html at the top level and all your assets organized normally, and then tell github to use that branch as gh-pages branch. – Mike 'Pomax' Kamermans Jan 01 '19 at 07:25

2 Answers2

1

Apparently, as you can read on github pages doc, you cannot configure it for having the "main page" on another place who aren't the root of repository, or a folder called docs.

As a workaround, you can try some options:

  1. You can try to use an .htaccess document, for configuring a 301 redirect. I didn't know if this can work on github pages, because I haven't use these service.
  2. You can try to put an index.htm on the root of the repository, and do a redirect from it. Check this code:

    <meta http-equiv="refresh" content="0; url=http://example.com/" />

If you need more information about how to do a redirect on html, check this question on SO: Redirect from an HTML page. But think, the redirect will only work for each file you create (for example, index.htm). And they only can have one destination. This option will not allow you to redirect any request to the page to the /html/ folder.

Sakura Kinomoto
  • 1,784
  • 2
  • 21
  • 30
  • htaccess will do nothing, gh-pages don't run on Apache. – Mike 'Pomax' Kamermans Jan 01 '19 at 07:26
  • I found method #2 to work. I created an index.html and redirected it to the main one within the folder. Although it doesn't look as nice as I'd like, it'll work for now. Thanks dude! –  Jan 01 '19 at 07:30
0

You need to use the relative path to your index.html. So you'd have

<a href="../html/index.html">FIRST LAST</a>
ibn_Abubakre
  • 112
  • 7