Lesson 7.3: Creating Your Website
In this lesson, you'll enhance your website with additional features and practice essential file management skills. This hands-on work demonstrates your ability to organize, edit, and manage web content.
Enhancing Your Website
Let's add more content and features to your website:
Adding Images
Add images to make your website more visually appealing:
Updating HTML to Include Images
Modify your HTML files to include images:
Add this to your index.html header:
Welcome to My Website
This is my first website running on Nginx!
Adding CSS for Images
Update your CSS to style the logo:
Add this to your CSS file:
.logo {
max-width: 150px;
height: auto;
margin-bottom: 1rem;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
header {
display: flex;
flex-direction: column;
align-items: center;
gap: 1rem;
}
File Management Operations
Practice essential file management skills:
Copying Files
Create backups and organize your files:
Moving and Renaming Files
Removing Files
Advanced File Operations
Practice more advanced file management techniques:
Finding Files
Welcome to My Website
# Find files modified recently $ find ~/my-website -mtime -7File Permissions Management
Content Updates and Maintenance
Learn how to maintain and update your website content:
Version Control with Git
Use Git to track changes to your website:
Creating a Sitemap
Create a sitemap to help search engines:
Add this content to sitemap.xml:
http://localhost/index.html
2024-12-10
weekly
1.0
http://localhost/about.html
2024-12-10
monthly
0.8
http://localhost/contact.html
2024-12-10
yearly
0.6
Creating a Robots File
Create a robots.txt file to control search engine access:
Add this content to robots.txt:
User-agent: *
Allow: /
Disallow: /private/
Sitemap: http://localhost/sitemap.xml
Website Testing and Validation
Test your website thoroughly:
HTML Validation
Link Checking
Performance Testing
Backup and Recovery
Implement proper backup strategies:
Automated Backups
Add this backup script content:
#!/bin/bash
# Website backup script
BACKUP_DIR="$HOME/my-website-backups"
WEBSITE_DIR="$HOME/my-website"
DATE=$(date +%Y%m%d_%H%M%S)
# Create backup directory
mkdir -p "$BACKUP_DIR"
# Create compressed backup
tar -czf "$BACKUP_DIR/website_$DATE.tar.gz" -C "$WEBSITE_DIR" .
# Keep only last 7 days of backups
find "$BACKUP_DIR" -name "*.tar.gz" -mtime +7 -delete
echo "Backup completed: website_$DATE.tar.gz"
Restoring from Backup
Practice Exercises
Exercise 1: File Management Practice
- Create a new directory structure
- Move files to appropriate locations
- Create copies of important files
- Remove temporary files
- Check and fix permissions
Click for solution
Exercise 2: Content Enhancement
- Add images to your website
- Update CSS to style images
- Create a sitemap.xml file
- Add a robots.txt file
- Test all pages in browser
Click for solution
Exercise 3: Backup and Recovery
- Create backup script
- Run automated backup
- Test backup restoration
- Set up scheduled backups
- Verify backup integrity
Click for solution
What's Next?
Excellent! You've created a complete website with proper file management. Next, we'll put all your skills together in comprehensive project exercises.
Key Takeaways
- Organize website files in logical directory structure
- Use proper file permissions for web content
- Implement backup strategies for data protection
- Create sitemap and robots files for SEO
- Test website functionality thoroughly
- Use version control for tracking changes
Linux 101