Skip to content

hackaye/11ty-to-compute

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

28 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Hello 11ty!

Oh hi! Welcome to your new blog. 🎑

Open in GitHub Codespaces

You can publish this site to Fastly for free!

This project is a blog powered by Eleventy, a lightweight static site generator that builds plain HTML files for quick loading by your visitors.

In this guide we'll show you how to deploy your blog to Fastly Compute for super fast performance – your great posts will immediately be available for everyone, everywhere all at once. πŸͺ„

You can alternatively deploy your blog to other platforms, like GitHub Pages.

Remix your own blog

Fork your own copy of this repo, click Code > Codespaces and create a new Codespace to edit the project.

Give the Codespace a minute or two to start up – it'll automatically build and run your new website, opening a preview to see your site update as you edit!

The blog in a Codespace

  • When your website preview opens, click the πŸ”Ž Split button at the bottom so that you can see the site side by side with your code.
  • You can close [x] the Terminal while you work.

Get to know your blog

You can make edits in the files by opening them from the left sidebar. Your blog preview will update as you edit!

The files you'll want to edit are mostly in the source and assets directories:

πŸ“ Edit the post content and add new posts in source/posts.

πŸ’‘ Change your site HTML in the source/_layouts files.

ℹ️ Edit the metadata for your site in the source/_data folder.

🎨 Change your site style rules in assets/style.css.

πŸ–ΌοΈ Add images in the assets/ folder – you'll find an example of adding an image to a post in source/posts/fourth-post.md.

🚨⚠️ Danger zone: There are directories in the project that you might want to be careful with..

  • The _site folder is autogenerated by 11ty so best not to edit in there.
  • The _app folder is autogenerated by the Fastly tooling so you should only edit in there if you want to change the Compute app you deploy to the edge.
  • The helpers folder contains the bash scripts that run when your project starts and when you hit the πŸš€ Publish button.

Share your draft site

Share your draft site with collaborators by opening πŸ’» Terminal > PORTS.

Change private to public by right clicking your running port and choosing from the options.

Change the port settings

Copy the URL to your clipboard and share it πŸ“‹.

Copy the URL

Deploy your blog to Fastly Compute

Ready to share your site with the world? Deploy it to Fastly to make it available for everyone everywhere all at once!

Grab a Fastly API key from your account and add it to your GitHub repo:

  • Sign up for a free Fastly developer account
  • Grab an API Token from Account > Personal Profile > API Tokens > Create Token
    • Type: Automation
    • Role: Engineer
    • Scope: Global (deselect the Read-only access box)
    • Access: All services
    • Expiration: Never expire
  • Copy the token value into your GitHub repo
    • Open Settings > Secrets and Variables > Codespaces
    • Create a New repository secret
    • Enter the name FASTLY_API_TOKEN
    • Paste your token value in and save

Back in your Codespace, you should see a prompt to reload for the new environment variable so go ahead and click that.

Hit the πŸš€ Publish button and watch the Terminal output for your new site address!

Open it in a new tab and tell everyone you know. πŸ“£

🎒 Whenever you update your content, like adding a new blog post, hit the πŸš€ Publish button again to go live!

How this project works 🧐

This project uses the Fastly JavaScript Static Publisher to turn your blog into a serverless application that runs at the network edge, near your users.

  • The 11ty framework builds your posts into the HTML and other files that make up your website, placing them in the _site folder.
  • The Static Publisher uses those files to scaffold a Compute app that compiles into Webassembly (Wasm) that can run fast and securely on the Fastly network – you'll find the Compute code in _app after you deploy.
  • When you publish, the project deploys the app to Fastly, creating a service and uploading the Wasm to it.
  • It then then publishes your content to a KV Store – a key-value store that also runs on Fastly and that your app can talk to.

Your app only needs deployed to Fastly once, after that we just update the new content to your KV Store and your Compute app will pull your posts from there.

βš™οΈ The settings we use to create the guided experience in Codespaces are in the .devcontainer/ folder.

🧰 You'll find the Fastly CLI commands we use under the hood in the helpers/publish.sh script.

Extensions

This project uses the following extensions from the dev community! πŸ™Œ

Keep going! πŸ›Έ

Don't stop there, add a domain to your new site.

Check out lots more tips on using the Static Publisher in its repo README. Note that if you make changes to the Compute code, you'll need to run a separate deploy command to deploy your changes to Fastly as the πŸš€ Publish button will only deploy once, after that it'll just update your content.

πŸ›Ÿ Get help on the community forum.

About

An eleventy blog you can publish to Fastly Compute!

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Nunjucks 33.0%
  • CSS 31.0%
  • Shell 18.4%
  • JavaScript 17.6%