Mobile app version of vmapp.org
Login or Join
Deb1703797

: Internal links don't work and accidentally link to landing page Contributing for the first time in a website project and editing an existing website. One list item looks like this: <li>li

@Deb1703797

Posted in: #Html #Links

Contributing for the first time in a website project and editing an existing website. One list item looks like this:

<li>li class="public-nav hide" id="signup-nav"><a href="signup"><button class="btn btn-primary">Get Started for Free</button></a></li>


As you can see, the internally stored page "signup" is referenced in this list item. However, when I want to replicate this referencing pattern, it does not work.

For example, I tried to link to the signup page like this:

<div class="first-content text-small">Are you a new user? <a href="signup">Get started for free.</a></div>


However, the link when clicked leads to the landing page rather than to the sign-up page. Why could that be and how to fix?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Deb1703797

2 Comments

Sorted by latest first Latest Oldest Best

 

@Angela700

What I happen to do with every page I made is use the following tag:

<base href="http://example.com/path/to/majority/">


What it does is set the default path (instead of current path) for all relative URLs so you know exactly what page is loaded.

For example. If someone went to example.com/specialpage/index.html and the HTML code passed to the browser contained this:

<a href="signup">sign up</a>


and a user clicked on that "sign up" link, then they will be taken to:
example.com/specialpage/signup

But if the HTML code at example.com/specialpage/index.html also contained:

<base href="http://example.com/differentpage/">


Then when someone clicks on the "sign up" link, they will be taken to:
example.com/differentpage/signup

And that's because the default folder is defined in the base tag.

The other alternative you have is to use the full path in the link itself. For example:

<a href="http://example.com/differentpage/signup">sign up</a>


The above will take you directly where you want the user to end up regardless of the presence of the BASE tag.

10% popularity Vote Up Vote Down


 

@Bryan171

Remember that "signup" is a relative URL. It opens the URL signup relative to the URL of the page in which that link is in.

For example, on example.com/ if you add href="signup", it'll lead to example.com/signup.

But on example.com/about/index.html if you add the same, it'll go to example.com/about/signup.

Since that URL isn't valid, the server might be redirecting you to the landing page.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme