Hi, I have a question.I have a folder called Web Site.Inside it I have 2 folders n.1 and n.2.Inside folder1 I have a page called index.htm.Inside folder2 I have a page called home.htm.How do I link index.htm with home.htm and viceversa? I appreciate your help thank you.

Dani AI

Generated

Nice summary and resolution in the thread — and correctly pointed out that relative linking is the usual, portable approach and covered absolute paths. A few extra, practical points not shown above that commonly bite people working with folders like "Web Site", "n.1" and "n.2":

Root-relative links (start with a slash) avoid repeated .. segments and are stable when the site is served from a consistent root. Note that spaces and some punctuation in folder names must be URL-encoded (spaces → %20), so a root-relative link to a folder named Web Site looks like this:

<a href="/Web%20Site/n.2/home.htm">Home</a>

Using a <base> tag can simplify many cross-folder links — set a single base and then use shorter relative paths — but be careful: base changes how every relative URL in the document resolves.

Local testing can behave differently from a web server (file:// paths, Windows case-insensitivity). To mirror production, run a tiny local HTTP server in the site root (Python 3 example):

# run from the site root folder
python -m http.server 8000

Common troubleshooting checklist: inspect the network/console for the resolved URL and any 404s; make sure forward slashes / are used (not backslashes); check filename and folder name case on Linux servers; avoid spaces or dots in folder names where possible (prefer web-site or web_site); be consistent with .htm vs .html. Thread contributors did what was needed and confirmed it worked — kudos to everyone, including , for closing the loop.

Recommended Answers

All 6 Replies

If you are using relative links, use .. to indicate the level above.
So to link from index.htm to home.htm:

<a href="../folder2/home.htm">link to home</a>

To link from home to index, do the same but replace folder2 with folder 1, and home.htm with index.htm.

Hmm on a second read-through, I see you said link with, not to. If my previous post does not address your question correctly, please clarify what you mean.

Dear 'Fiorentino01^', there are 2 ways to do this:

  • Write the full path
    Ex: <a href="http://www.domain.com/web-site/2/home.html">go to Home</a> (This will be placed in the page index.html) and same thing with home.html

  • Write the path starting from the location of the file you are coding
    Ex: you are coding the page index.html, just write <a href="../2/home.html">go to Home</a>

../ is to go to the upper folder (Parent directory)

Here's a good tutorial for HTML paths
http://www.coffeecup.com/help/articles/absolute-vs-relative-pathslinks/

Good Luck

Write the full path

This is called absolute path. This style is not recommended when you works on a website. It is easy on web developers but it is not really portable and not easy to maintain. Also, it could come and bite you when there are some changes in the future.

Write the path starting from the location of the file you are coding

This is called relative path which is supposed to be done in web developing. The .. means to go up one level from the directory/folder where the current being displayed location is. For example, the current location of the displayed HTML file is and you define a link inside the page1.html as ../mypage.html. As a result, the path resulted from it becomes because the .. move the location from to .

Thanks to all of you Problem SOLVED!!

Problem solved thank all who contributted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.