W
W
wp_starter2020-05-15 11:36:44
HTML
wp_starter, 2020-05-15 11:36:44

How to properly set paths in GitHub Pages?

How should the paths be set correctly so that the site is displayed correctly for everyone?

For example, in layout

<link rel="stylesheet" href="./assets/css/normalize.css">
  <link rel="stylesheet" href="./assets/css/style.css">


I transfer the same thing to GitHub Pages and everything works. But for some users, styles are not loaded until I remove the dot and slash in the ./assets path and leave only assets

<link rel="stylesheet" href="assets/css/normalize.css">
  <link rel="stylesheet" href="assets/css/style.css">


What is the reason that some norms open, while others have problems?
Is there a way to have GitHub write full paths on its own?
Something like this

<link rel="stylesheet" href="https://user.github.io/site/assets/css/style.css">
  <link rel="stylesheet" href="https://user.github.io/site/assets/css/normalize.css">

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Danil Shchuchkin, 2020-05-15
@varkrift

Try to put only a slash instead of a dot and a slash , because the dot slash indicates the current directory, and the slash is the root of the site. Something like this:

<link rel="stylesheet" href="/site/assets/css/normalize.css">
<link rel="stylesheet" href="/site/assets/css/style.css">

A
Andrey Nikiforov, 2020-05-16
@squitcher

all because it is a subdomain, do it without slashes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question