Skip to content

How do I serve css along with an .html file? #505

Answered by cprosche
cprosche asked this question in Q&A
Discussion options

You must be logged in to vote

Found my own answer! I needed to add a route to serve my static content and place that content in it's own folder so that /:path+ doesn't cause any issues.

router.get("/", async (context) => {
  await context.send({
      root: Deno.cwd(),
      index: `index.html`
  })
});

router.get("/static/:path+", async (context) => {
  await context.send({
    root: Deno.cwd(),
  });
});

And my link tag in my html.
<link rel="stylesheet" type="text/css" href="/static/style.css"/>

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by cprosche
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant