1

I have different pages for my website and I have put those HTML files in a folder X and inside there are index.html, main.html, etc and there are more different pages for different articles. Now that I have separated those articles in different folders A, B, C for easy access inside folder X but now my index.html, main.html etc files are not linking to the article pages. And not even article files are linking to each other.

Look at image for a better understanding of my problem.

        <a class="active" href="Index.html" target="_blank">Home</a>
        <a href="#" target="_blank">Anime Stuff</a>
        <a href="Youtube.html" target="_blank">YouTube</a>
        <a href="Contact Me.html" target="_blank">Know Me</a>

Look At The Image To Understand More Clearly About My Problem!

WOUNDEDStevenJones
  • 5,150
  • 6
  • 41
  • 53
Nelie
  • 43
  • 7

3 Answers3

1

So IF 'X' is your main folder any files in that folder will be accessed like this

<a href="./index.html">Index</a>
<a href="./contact.html">Contact</a>
<a href="./MainContent.html">Main Content</a>

For A, B, and C which are your sub-folders inside X, files can be accessed like this

For Folder A: <a href="./A/index.html">Index</a>

For Folder B: <a href="./B/index.html">Index</a>

For Folder C: <a href="./C/index.html">Index</a>

Data Monger
  • 106
  • 10
  • Still, It Is Showing File Was Not Found. When Clicking On The Link. What Should I Do Now? – Nelie Jun 16 '20 at 21:06
0

Linking to Relative Page

Example:

project-folder/
|—— about.html
|—— contact.html
|—— index.html

<a href="./contact.html">Contact</a>
sonEtLumiere
  • 4,461
  • 3
  • 8
  • 35
0

The cleanest way to link between these pages is to use URLs relative to your document root. See Absolute vs relative URLs for more information, but starting each URL with / (making your URLs relative to the document root) will help a lot.

Example: let's treat your Project Money directory as your document root, and let's say these are being accessed at http://local.website.com/. This means to access your homepage, you just go to http://local.website.com/ or http://local.website.com/index.html and it loads your homepage. Additionally, http://local.website.com/contact.html will load your contact page, and http://local.website.com/youtube.html will be your YouTube page. Now to deal with subdirectories. http://local.website.com/A/article1.html will load the article1.html page within the A directory.

So to link to your article1.html page from anywhere else, use /A/article1.html as the href value, and similarly to link to your homepage from anywhere else, you can use /index.html. Using the URLs relative to the document root makes linking between pages a lot cleaner than relative to the current path (./A/article1.html, ./article1.html, article1.html, ../index.html, etc). See https://stackoverflow.com/a/21828923/1499877 for additional examples, which also links to additional resources.

WOUNDEDStevenJones
  • 5,150
  • 6
  • 41
  • 53
  • Man, I Am Still Running In The Same Problem. What Should I Do Now? – Nelie Jun 16 '20 at 21:41
  • can you expand what you mean by "the same problem"? You should be able to use `href="/A/article1.html"` to link to your `article1` page _from any other page_ when you use the path relative to document root like this - compared to using `href="./A/article1.html"` on `index.html`, or `href="../A/article1.html"` on `/B/article2.html` – WOUNDEDStevenJones Jun 16 '20 at 22:02
  • I Did Exactly What You Told Me, But I Don't Know For Some Reason When I Click On Link In The Page It Shows **"File Was Not Found."** – Nelie Jun 17 '20 at 20:33
  • What is the URL of the page you're starting on, what is the value of the `href` attribute on the link you're clicking, and what is the URL you're ending up on? – WOUNDEDStevenJones Jun 17 '20 at 20:36
  • Starting Page URL: (file:///D:/Madeline's%20Stuff/Sublime%20Text%203/Project%20Money/High%20School%20DxD/HSDxD.html), The Value Of The **Herf Attribute**: (Know Me), Where I'm Ending Up When I Click The Link: (file:///D:/Madeline's%20Stuff/Sublime%20Text%203/Project%20Money/High%20School%20DxD/Contact%20Me.html) – Nelie Jun 17 '20 at 21:13
  • Where are you expecting to end up after clicking your link? – WOUNDEDStevenJones Jun 17 '20 at 21:29
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/216169/discussion-between-woundedstevenjones-and-nelie). – WOUNDEDStevenJones Jun 17 '20 at 21:32