Skip to content
← Back to Community
html question
Profile icon
paulinbacana

Hello guys, can someone tell me if i can create one .html file and call this file to my index.html??? (sorry for bad english 😅)

Voters
Profile icon
Luke042
Profile icon
coolbub413
Profile icon
paulinbacana
Comments
hotnewtop
Profile icon
notGilbert

You need to use <a> (anchor) not the <link> tag.

<link> is basically metadata to include things like preloading and stylesheets

<a href="/path/to/file.html">This is a link</a>

this would create a clickable link that will bring you to another page

Profile icon
paulinbacana

@notGilbert I'm not tring to do this, but thanks to try help me :)

Profile icon
notGilbert

@paulinbacana ohh.. do you mean like copying and pasting the file into index.html?

You can:

  • use a web framework like ejs or danjo (requires extra setup)

  • use some Javascript:

// this is the element to put the HTML in const element = document.querySelector('body'); // this will fetch the HTML from the file and then put it inside that element fetch('/path/to/file.html').then(async r => { element.innerHTML = await r.text(); });
Profile icon
paulinbacana

@notGilbert Ok thanks

Profile icon
LAMAQDAHODWALA

Uh no... you can put all your html in one file. If you want to use html extending like you seem to be trying to do here, you can use a web framework, like flask or django, and use html extending from there.

Profile icon
paulinbacana

@LAMAQDAHODWALA I don't know how to do this, so i'm thinking to put the body tag in the index.html file