Full Width Layout

Full Width Layout Implementation

Overview

Removed excessive left and right margins from the Hugo documentation to utilize the full page width.

Problem

The default Hugo Book theme had:

  • .container with max-width: 80rem and margin: 0 auto
  • This created large empty spaces on both sides of the content
  • Wasted screen real estate, especially on wide monitors

Solution

Created /static/css/full-width-layout.css with the following changes:

1. Container Full Width

.container {
  max-width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

2. Main Flex Container

main.flex {
  max-width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

3. Content Padding (Responsive)

.book-page {
  /* Mobile: 1rem padding */
  /* Tablet: 1.5rem padding */
  /* Desktop: 1.5rem 2rem padding */
  /* Large Desktop: 2rem 3rem padding */
}

Benefits

More Content Space: Content now spans the full width of the browser ✅ Better Use of Screen: No wasted white space on sides ✅ Responsive: Appropriate padding on all screen sizes ✅ Readable: Still maintains comfortable padding for reading ✅ Professional: Modern full-width layout like most modern documentation sites

Layout Structure

┌─────────────────────────────────────────────────────────┐
│ Sidebar (14rem)  │  Content (Full Remaining Width)      │
│                  │                                       │
│ - Logo           │  ┌─────────────────────────────────┐ │
│ - Search         │  │  Page Content                   │ │
│ - Menu Items     │  │  (Padding: 1.5-3rem responsive) │ │
│                  │  │                                 │ │
│                  │  └─────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘

Screen Size Breakpoints

Screen SizeSidebar WidthContent Padding
Mobile (<768px)Hidden/Overlay1rem
Tablet (769-1200px)14rem1.5rem
Desktop (1201-1399px)14rem1.5-2rem
Large (1400-1919px)13rem2-3rem
XL (1920px+)12rem2-3rem

Files Modified

  1. Created: /static/css/full-width-layout.css - New full-width layout styles
  2. Updated: /layouts/partials/docs/inject/head.html - Added full-width CSS first (before custom-sidebar.css)

Load Order (Important!)

CSS is loaded in this order for proper cascading:

  1. full-width-layout.css ← Remove margins/padding
  2. custom-sidebar.css ← Sidebar styling
  3. sidebar-themes.css ← Theme variations
  4. sidebar-components.css ← Additional components

Testing

Test the layout on:

  • Chrome DevTools (responsive mode)
  • Firefox Developer Tools
  • Safari Web Inspector
  • Actual mobile devices
  • Different screen resolutions (1920x1080, 2560x1440, 3840x2160)

Rollback

To revert to the original layout with margins:

  1. Remove <link rel="stylesheet" href="{{ "css/full-width-layout.css" | relURL }}"> from head.html
  2. Or delete /static/css/full-width-layout.css

Performance

  • File Size: ~1.1KB (minified)
  • HTTP Requests: +1 CSS file
  • Render Impact: Minimal (overrides existing styles)

Result: Documentation now uses the full browser width with appropriate responsive padding for optimal content display! 🎉