Ask coding questions

← Back to all posts
How do you make links for your website?
maxina (63)

So I'm working on a website with node.js and socketIO. However, I don't know how to make links for each html file.
Lets say for example I have a website called test.com. And then I want there to be a link on the site called test.com/signup.html. How do I do so?

Answered by Coder100 (18241) [earned 5 cycles]
View Answer
Comments
hotnewtop
Coder100 (18241)

That's exactly right. test.com/signup.html. Make sure you also serve the file in your js, like this:

app.get("/signup.html", (req, res) => {
  res.sendFile(__dirname + "/signup.html");
});

assuming your file structure looks like this:

index.js
signup.html
ch1ck3n (2088)

<a href="/signup">signup</a> put that in your html

maxina (63)

@ch1ck3n lets say i have an html file called "signup_screen.html." How do I link to that html page?

ch1ck3n (2088)

@maxina <a href="signup_screen.html">here is the link</a>

maxina (63)

@ch1ck3n oohhh ok thats why it wasnt working. Thanks.

Can I do the

app.get("/signup.html", (req, res) => {
res.sendFile(__dirname + "/signup.html");
});

to multiple html files though? and if so, how do I do it?

ch1ck3n (2088)

@maxina

app.get("/signup.html", (req, res) => {
res.sendFile(__dirname + "/signup.html");
});
app.get("/moresignup.html", (req, res) => {
res.sendFile(__dirname + "/signup.html");
});
dolphin30 (0)

Well, first of all just use HTML, CSS, JS. and then use <a> tags. why do you need node.js and socketIO

maxina (63)

@dolphin30 uhhhh wdym why for sockets

ch1ck3n (2088)

@dolphin30 do you even understand the concept of backend

maxina (63)

@ch1ck3n ?
I'm just confused on what your trying to ask.

Yes I'm using html/css/javascript, and socketIO to send data online...