Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

Erick Martinez
Erick Martinez
2,894 Points

How to connect style sheet in GitHub to HTML file?

I can't seem to connect the CSS file to my HTML file in Github so my web page is only showing the HTML. They work locally on my computer, so IDK what I am doing wrong

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

It likely has to do with the path and/or file name but to know for sure, we'd have to see a link to your site :smiley: I look forward to hearing back! :sparkles:

4 Answers

Erick Martinez
Erick Martinez
2,894 Points

I deleted everything cause I am having a hard time with Git and Github. As you can see https://erickthemeeknerd.github.io/

fatal: No remote repository specified. Please, specify either a URL or a remote name from which new revisions should be fetched

Do you know why this happens? I delete my original repo and created a new one. I also deleted the folder in finder and created a new folder and "git init" that folder but when I do git pull I get this error. Also if I do "git branch add-index.html" I get this error

fatal: Not a valid object name: 'master'.

I am so confused

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! When you redid the git init, it created an entirely new local git repository. Before you can push or pull anything, you must first tell it where that remote repository is. Otherwise, it has no idea. That's exactly what it means when it says:

fatal: No remote repository specified. Please, specify either a URL or a remote name from which new revisions should be fetched

To specify a remote location you will need to type this line:

git remote add origin https://github.com/ErickTheMeekNerd/erickthemeeknerd.github.io.git

This command adds a remote location which we've named "origin" and points it to your GitHub repo. You should now be able to do push and pull commands as normal.

So something like:

git pull origin master

Hope this helps! :sparkles:

Erick Martinez
Erick Martinez
2,894 Points

AHHHHH I seeeeee. Thank you very much, Jennifer! That helps me understand it more. I have been searching Google and Youtube all night to understand Git more. This thing is confusing. One more question if you don't mind helping me. I still can't get the CSS file to connect to the HTML. I am using atom and in atom, I am right clicking the CSS file and copying the full path to the file which is "/Users/erickmartinez/Downloads/Code/erickthemeeknerd.github.io/style.css". I added it liked so

 <html>
  <head>
    <title>Erick's Portfolio</title>
    <link rel="/Users/erickmartinez/Downloads/Code/erickthemeeknerd.github.io/style.css">
  </head>

Do you know what I am doing wrong?

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Yes. you are pointing to a place on your computer. Besides that, the link is in the incorrect attribute. It should be in the href attribute. And GitHub doesn't have access to your computer :) What you need here instead of that big long line is:

<link rel="stylesheet" type="text/css" href="style.css">

This says, go find the style sheet named "style.css" that's located at the same level as this index.html and link it here.

Hope this helps! :sparkles:

edited for additional clarification

Obviously, it works from your computer because your computer can see its own file system. GitHub has no access to your file system at all. So the solution here is to use relative paths. This means that as long as that style sheet is at the same level as index.html, it will load it no matter where you put it later.

Erick Martinez
Erick Martinez
2,894 Points

YES, IT WORKED! Thank you, Jennifer! : )