Skip to content

Instantly share code, notes, and snippets.

@mekicha
Last active December 10, 2023 16:59
Show Gist options
  • Save mekicha/9f45a27da176dbaf9efc1e5e2d411fbf to your computer and use it in GitHub Desktop.
Save mekicha/9f45a27da176dbaf9efc1e5e2d411fbf to your computer and use it in GitHub Desktop.
Add bootstrap and font awesome libraries to a pug project. Add this to your layout.pug file in the views directory, generated by running `express --view=pug`
doctype html
html
head
title= title
link(rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'
integrity='sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u' crossorigin='anonymous')
link(rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css')
link(rel='stylesheet', href='/stylesheets/style.css')
body
block content
script(src='https://code.jquery.com/jquery-3.2.1.min.js'
integrity='sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4='
crossorigin='anonymous')
script(src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js'
integrity='sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa' crossorigin='anonymous')
<!--
The integrity and crossorigin attributes are used for Subresource Integrity (SRI) checking.
This allows browsers to ensure that resources hosted on third-party servers have not been tampered with.
-->
@tedlawlor
Copy link

Can you help explain why there are links to bootstrap and the fonts in the head and also scripts in the body

@Sevicode
Copy link

Can you help explain why there are links to bootstrap and the fonts in the head and also scripts in the body

It is best practice to put the links to your stylesheets in head and link to your scripts in the body. Although you can leave your script in the head section as well. depends on the project and what you would like to load first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment