DEV Community

Cover image for Publishing an Eleventy site to Github Pages

Publishing an Eleventy site to Github Pages

Donna Hogan on March 03, 2020

Eleventy is a relatively new static site generator. I've heard it's "almost fascinatingly simple", and I have a situation at work that is perfect ...
Collapse
 
ddhogan profile image
Donna Hogan • Edited

Thank you for the feedback, Erich!
Your reply inspired me to look into it a little further, and learned I can use the built-in URL filter since I'm deploying to a sub-directory.

Using this, one of my links looks like this: <a href="{{ '/myFirstPost' | url }}">First Post</a>, where the | is the filter operator, and url indicates to use the url filter.

All I had to change was the formatting of those links to other posts, and add the trailing slash to the pathPrefix in .eleventy.js.
This also means I can delete _data/site.json, since there's no need to declare the pathPrefix there too.

I am going to update this mini-tutorial, thank you again!

Collapse
 
amwelles profile image
Autumn Welles

One additional step I needed to follow was adding an empty .nojekyll file to my main branch. :)

Collapse
 
ddhogan profile image
Donna Hogan

Interesting! What did adding that file fix?

Collapse
 
eys profile image
Eystein Mack Alnæs • Edited

Just want to say thank you. Even 2.5 years later this is what finally got me on the right track and fixed my deploy.