Skip to content

Instantly share code, notes, and snippets.

@ramuta
Created May 9, 2019 02:54
Show Gist options
  • Save ramuta/6dfa537d66b32b2be99d58cf4efc36f7 to your computer and use it in GitHub Desktop.
Save ramuta/6dfa537d66b32b2be99d58cf4efc36f7 to your computer and use it in GitHub Desktop.
Jinja templates structure example (with Bootstrap)
{% extends "base.html" %}
{% block title %}About me{% endblock title %}
{% block content %}
<h1>About me</h1>
<p>Here are some things about me...</p>
{% endblock content %}
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>{% block title %}{% endblock title %}</title>
</head>
<body>
{% block content %}
{% endblock content %}
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
{% extends "base.html" %}
{% block title %}Contact me{% endblock title %}
{% block content %}
<h1>Contact</h1>
<p>Feel free to contact me!</p>
<input type="email" placeholder="Enter your email address">
<textarea placeholder="Enter your message"></textarea>
<button>Send</button>
{% endblock content %}
{% extends "base.html" %}
{% block title %}My homepage{% endblock title %}
{% block content %}
<h1>Hello world!</h1>
<p>This is index.html page</p>
{% endblock content %}
{% extends "base.html" %}
{% block title %}My photos{% endblock title %}
{% block content %}
<h1>My photo album</h1>
<img width="300px" src="https://www.drupal.org/files/project-images/Ninja_Happy800.png">
{% endblock content %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment