#How could I add an external .html page into the website?

1 messages · Page 1 of 1 (latest)

astral basin
#

Hi I have a index.html file I generate using another framework how could I connect this page to my astro website on website.com/newdir?

prime reefBOT
#

Hi @astral basin. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

To connect your index.html file to your Astro website, you would need to convert it into an Astro page. Astro pages use the .astro file extension and support the same features as Astro components.

Here are the steps you can follow:

  1. Create a new file in your Astro project directory at src/pages/newdir/index.astro. This will be your new Astro page in the project.

  2. Copy the content of your index.html file and paste it into your new index.astro file.

  3. If your index.html file contains any JavaScript, you would need to move it into the frontmatter of your .astro file. The frontmatter is the section between the --- dashes at the top of the file. Any JavaScript code in the frontmatter runs in the terminal, not in the browser.

Here's an example of what your index.astro file might look like:

---
// Your JavaScript code goes here
console.log('This runs in your terminal, not the browser!');
---
<!-- Your HTML code goes here -->
<html> 
  <body> 
    <h1>Hello, World!</h1> 
  </body>
</html>
<style> 
  h1 { color: orange; }
</style>

Please note that Astro emphasizes minimized JavaScript usage and optimized loading times for an improved user experience. So, it's recommended to only include the necessary JavaScript in your Astro pages.

For more information, you can refer to the Astro Pages (https://docs.astro.build/en/core-concepts/astro-pages/) section in the Astro documentation.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: