Practice: Building & Publishing a Titanic Insights Website
titanic_quarto_website
, run:_quarto.yml
, index.qmd
, about.qmd
, etc._quarto.yml
)_quarto.yml
:
_quarto.yml
. Modify it to control structure and appearance. Example below.project:
type: website
output-dir: docs # For GitHub Pages
website:
title: "Titanic Data"
navbar:
left:
- href: index.qmd
text: Home
- href: pclass_analysis.qmd
text: Survival by Class
- href: age_fare_analysis.qmd
text: Age vs. Fare
- about.qmd
page-footer: "Built with Quarto by Your Name"
format:
html:
theme: cosmo
css: styles.css
toc: true
code-fold: true
index.qmd
)index.qmd
(Homepage):
---
title: "Titanic Insights"
---
## Exploring the Titanic Dataset
This website presents a brief analysis of the passenger data from the RMS Titanic. The analysis includes:
- Survival rates based on passenger class.
- The relationship between passenger age and the fare they paid.
Use the navigation bar above to explore the different analyses.
The data used is the well-known Titanic dataset.

*Source: Smith College*
images
folder) and link to it like 
.pclass_analysis.qmd
(Survival by Class)pclass_analysis.qmd
in your project root.---
title: "Survival Rate by Passenger Class"
---
This page analyses survival rates by socio-economic class (Pclass).
First, let's load libraries and data.
```python
#| label: setup-libs-data-pclass
#| echo: true
#| eval: true
#| message: false
#| warning: false
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
titanic_df = pd.read_csv('data/titanic.csv')
pclass_analysis.qmd
(cont.)### Calculating and Visualising Survival Rates
```python
#| label: pclass-survival-plot
#| echo: true
#| eval: true
#| fig-cap: "Survival Rate by Passenger Class"
pclass_survival_rate = titanic_df.groupby('pclass')['survived'].mean().reset_index()
print("Survival rate by Pclass:")
print(pclass_survival_rate)
plt.figure(figsize=(8, 5))
sns.barplot(x='pclass', y='survived', data=pclass_survival_rate, palette='viridis', hue='pclass', dodge=False, legend=False)
plt.title('Survival Rate by Passenger Class')
plt.xlabel('Passenger Class')
plt.ylabel('Survival Rate')
plt.xticks(ticks=[0,1,2], labels=['1st Class', '2nd Class', '3rd Class'])
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()
The bar chart shows that first-class passengers had a higher survival rate. Third-class passengers had the lowest.
age_fare_analysis.qmd
(Age vs. Fare)age_fare_analysis.qmd
in your project root.---
title: "Age vs. Fare Analysis"
---
This page explores passenger age vs. fare paid.
```python
#| label: setup-libs-data-agefare
#| echo: true
#| eval: true
#| message: false
#| warning: false
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
titanic_df = pd.read_csv('data/titanic.csv')
age_fare_analysis.qmd
(cont.)### Scatter Plot: Age vs. Fare
Passengers with unknown age are excluded.
```python
#| label: age-fare-scatter-plot
#| echo: true
#| eval: true
#| fig-cap: "Scatter Plot of Age vs. Fare, Coloured by Survival Status"
titanic_age_fare = titanic_df.dropna(subset=['age'])
print(f"Number of passengers with known age: {len(titanic_age_fare)}")
plt.figure(figsize=(10, 6))
sns.scatterplot(x='age', y='fare', hue='survived', data=titanic_age_fare, alpha=0.7, palette={0: '#377eb8', 1: '#ff7f00'})
plt.title('Age vs. Fare (Coloured by Survival)')
plt.xlabel('Age (Years)')
plt.ylabel('Fare Paid')
plt.legend(title='Survived (0=No, 1=Yes)')
plt.grid(True, linestyle='--', alpha=0.7)
plt.show()
The scatter plot shows passenger distribution by age and fare. Some younger passengers paid high fares.
.qmd
and _quarto.yml
files.titanic_quarto_website
), run:This builds the website in the docs
folder. Look for errors!
Preview Locally (Recommended):
Ctrl+C
in terminal to stop.titanic-quarto-insights
).main
, Folder: /docs
. Click “Save”.https://YOUR_USERNAME.github.io/YOUR_REPONAME/
).If you have extra time, turn an analysis page into a revealjs
presentation.
pclass_analysis.qmd
(or a copy):---
title: "Survival Rate by Passenger Class"
format:
revealjs: # Or add alongside html format
slide-level: 3 # H3 headings become slides
---
revealjs
:pclass_analysis.html
as a presentation.