1

I would like all my project pages to have the same custom style. But for now I only see that every project page can be configured separately (choosing default theme from Setting of the project or creating gh-pages branch with the source files).

Is there any way to archive what I want? For example, to write custom style in my username.github.io repo and all project could use that styles to create pages under username.github.io/projectname with the provided custom styles.

vrom911
  • 694
  • 1
  • 5
  • 16

1 Answers1

0

If your username.github.io repo is public, then you could access the styling file(s) from any other repo.

In username.github.io, let's say there's a file username.github.io/styling/main.css. In your layouts for any other projects, you can link to the file like a regular external css link:

<link rel="stylesheet" href="https://raw.githubusercontent.com/username/username.github.io/styling/main.css">

raw.githubusercontent.com has Access-Control-Allow-Origin=*. It accepts all incoming CORS requests, so you don't have to worry about CORS issues. Also, <link> tags get the respective files using GET requests, which don't trigger CORS preflight requests.

DC.Azndj
  • 1,346
  • 12
  • 13
  • If one use jekyll, files at `raw.githubusercontent.com` will be the source version and not the generated one. Plus : `raw.githubusercontent.com` is not returning the correct content-type. – David Jacquel Jun 22 '18 at 16:20