SlideShare una empresa de Scribd logo
1 de 65
Descargar para leer sin conexión
…there was a time before
WordPress
One file per page
Assemble pages by including
common components
Mix in data from other sources
Emerging trends
• DRY
• Eliminate duplicate content
• Separate concerns
• Improve productivity
Thanks PHP
They matter too
But what about the content authors?
Content is a first class citizen
Further separation of concerns
• Users enter content using a GUI
• Programmers create templates that utilize the user-entered content
• Web pages generated on demand
Sounds simple?
It’s not
• With (pretty much) any CMS:
• Wrangling together templates and data is complicated
• The process is demanding and involves needless work
Most CMS-based websites
Writes ReadsExpensiveModerate
Some CMS-based websites
Writes ReadsCheapModerate
Thanks caching!
“The stack” stacks up
HTTP Accelerator (Varnish)
Web Server (Apache)
Application Server (WordPress/PHP)
Database (MySQL)
Object Cache
(MemCached)
File System
Too far?
Do you build a solution for your
problem or do you fit your problem
into a solution?
Build a solution
• We have the tools:
• Static site generators
• Rapid application frameworks
• APIs
• CMSs / Writing rooms
Big problems
Tiny solutions
Why static sites
• Fast
• Secure
• Scalable
• Simple themes and integrations
• Own conventions, languages, and tools
• Excellent version control story
The generators help!
Build
HTML
JS SVGCSS
GIF JPGPNG
Source
HTML
COFFEE SVG
TWIG ERB
SCSS
GIF JPGPNG
JSON YAML MD
Productivity, performance, security, scalability 

paid for with slow resource intensive build
processes
The new reality
Writes ReadsCheapExpensive
Requirements diminish
Server/CDN
File System
More hosting options open up
• Shared hosting
• VPS
• GitHub Pages (https://pages.github.com/)
• Dropbox (https://pages.github.com/)
• Google Drive (https://www.google.com/drive/)
• Amazon S3 (http://aws.amazon.com/s3/)
There are drawbacks
• Particularly with the concept of keeping content in flat files
• Hard to contribute (knowledge of Git)
• Hard to collaborate
Writing rooms to the rescue
• Contentful (https://www.contentful.com/)
• Prismic.io (https://www.prismic.io/)
• Pull in data through the API into a static build process
Focus
Admin interface for content creation and
collaboration
However…
• Subscription services
• Potential for vendor lock-in
• Lack of mature, open source alternatives
WordPress as a pure CMS
• WordPress can be used as an alternative to writing rooms like
Prismic.io and Contentful
• Content authors use WordPress to manage content and collaborate;
not to build web sites
• Content pulled out of WordPress and injected into static build
process
WP REST API
• Popular plugin that will be integrated into core
• Provides an HTTP REST API
• Extensive API for CRUD operations on comments, media, meta data,
posts, taxonomies, and users
• http://wp-api.org
Advanced Custom Fields Pro
• Popular plugin that allows for rapid creation of custom fields
• Supports many field types, including text, number, image, map,
links, and post references
• Rich ecosystem of extensions including repeaters
• http://www.advancedcustomfields.com
WP REST API Custom Fields
• Adds custom fields defined with ACF Pro to JSON output
• Inserts an object into the meta key with all your fields
• http://wordpress.org/plugins/wp-rest-api-custom-fields
Putting the backend together
• A 15-minute REST server with multi-user support, roles and
permissions, and an admin interface
1. Enable the aforementioned plugins
2. Setup friendly permalinks
3. Create custom post types if necessary
4. Setup custom fields if necessary
5. API accessible at /wp-json
Choosing a static site generator
• Comes in pretty much any language: C, C++, Java, Go, Haskell,
Erlang, JavaScript, Ruby, Python, PHP, etc.
• Choose a language you a comfortable with and enjoy working with
• Choose a system that is mature
• Choose a system that lets you work with many different types of
inputs, including remote content for maximum flexibility
Middleman
Hand-crafted frontend development

https://middlemanapp.com/
Key Features
• HTML, Markdown, YAML, and JSON format
• Templating language
• Asset pipeline
• Live reload
• Development server
• Common preprocessors and concat/minify out of the box
Useful Extensions
• Deploy
• Blog
• Pagination
• SVG Fallback
• Full list: https://directory.middlemanapp.com/#/extensions/all
Directory Structure
• Data
• Lib
• Source
• Images
• Javascripts
• Layouts
• Stylesheets
• Pages, posts, etc
Source
index.html.md
/about
Build
Data
/css /js/img
layout.html.erb logo.svg all.scss
_header.scss
_footer.scss
all.js
menu.coffee
feed.js
_header.html.erb
/layouts
Build
index.html
/about /css /js/img
logo.svg all.css all.js
logo.png
logo@2x.png
Dynamic Files
• Data is made available to our templates
• Useful for creating menus, lists, directories, etc.
• Pages can also be dynamically generated from data
sally.html roger.html sue.html
steven.html lisa.html
people
build
people.json
data
Dynamic Pages
In config.rb
people.each do |person|
proxy “people/#{person[‘name’]}.html”,
“layout/person.html”, locals: { person: person }
end
Data Source Library
In lib/wordpress.rb
class WordPress
include HTTParty
def initialize(uri)
self.class.base_uri uri
end
def posts
@posts ||= self.class.get(‘/posts?type=post’)
end
end
Dynamic Pages from Data Source
In config.rb
@wordpress = WordPress.new(“http://supersecret.dev/wp-json”)
@wordpress.posts.each do |post|
proxy “/blog/#{post[‘slug’]}/index.html”, “templates/post.html”,
locals: { post: post }
end
Expose Data Source to Templates
In config.rb
helpers do
def wordpress
@wordpress
end
end
Use Data Source in Templates
In source/blog/index.html
<% wordpress.posts.each do |post| %>
<div>
<h3><a href=“/blog/<%= post[‘slug’] %>/”><%= post[‘title’] %></a></h3>
<div><%= post[‘excerpt’] %></div>
</div>
<% end %>
Nicer than this!
<?php

if (have_posts()) {

while ( have_posts()) { 

the_post();

?>

<div>

<h3><a href=“<?php the_permalink(); ?>”><?php the_title(); ?></a></h3>

<div><?php the_excerpt(); ?></div>

</div>

<?php 

}

}

?>
There’s a plugin for that
• Hookpress
• Turns internal hooks into web hooks
• Recompile your site when content is updated
• https://wordpress.org/plugins/hookpress/
Middleman-WordPress Example
https://github.com/knicklabs/middleman-
wordpress-example
High Voltage - Building Static Sites With Wordpress-Managed Content

Más contenido relacionado

La actualidad más candente

EDS selection & implementation @ CCC
EDS selection & implementation @ CCCEDS selection & implementation @ CCC
EDS selection & implementation @ CCC
Molly Beestrum
 
Showcasing drupal
Showcasing drupalShowcasing drupal
Showcasing drupal
Opevel
 
High performance website
High performance websiteHigh performance website
High performance website
Chamnap Chhorn
 

La actualidad más candente (20)

Asp.Net 3 5 Part 1
Asp.Net 3 5 Part 1Asp.Net 3 5 Part 1
Asp.Net 3 5 Part 1
 
Web browsers and web document
Web browsers and web documentWeb browsers and web document
Web browsers and web document
 
SharePoint Framework, React and Office UI SPS Paris 2016 - d01
SharePoint Framework, React and Office UI SPS Paris 2016 - d01SharePoint Framework, React and Office UI SPS Paris 2016 - d01
SharePoint Framework, React and Office UI SPS Paris 2016 - d01
 
Basic Website 101
Basic Website 101Basic Website 101
Basic Website 101
 
EDS selection & implementation @ CCC
EDS selection & implementation @ CCCEDS selection & implementation @ CCC
EDS selection & implementation @ CCC
 
Overview of Coding Languages
Overview of Coding LanguagesOverview of Coding Languages
Overview of Coding Languages
 
Showcasing drupal
Showcasing drupalShowcasing drupal
Showcasing drupal
 
Static web documents
Static web documents Static web documents
Static web documents
 
Did wordpressdothat
Did wordpressdothatDid wordpressdothat
Did wordpressdothat
 
High performance website
High performance websiteHigh performance website
High performance website
 
Automate capabilities
Automate capabilitiesAutomate capabilities
Automate capabilities
 
Single page application
Single page applicationSingle page application
Single page application
 
dmBridge & dmMonocle
dmBridge & dmMonocledmBridge & dmMonocle
dmBridge & dmMonocle
 
WordPress Code Architecture
WordPress Code ArchitectureWordPress Code Architecture
WordPress Code Architecture
 
Drupal at the EBI
Drupal at the EBIDrupal at the EBI
Drupal at the EBI
 
sell idea
sell ideasell idea
sell idea
 
presentation on static website design
presentation on static website designpresentation on static website design
presentation on static website design
 
Presentation 1 Web--dev
Presentation 1 Web--devPresentation 1 Web--dev
Presentation 1 Web--dev
 
VFP & Ajax
VFP & AjaxVFP & Ajax
VFP & Ajax
 
Single Page Application
Single Page ApplicationSingle Page Application
Single Page Application
 

Destacado

Destacado (11)

Is Any Job Better Than No Job?
Is Any Job Better Than No Job?Is Any Job Better Than No Job?
Is Any Job Better Than No Job?
 
Why nosql also_why_somany
Why nosql also_why_somanyWhy nosql also_why_somany
Why nosql also_why_somany
 
Being there
Being thereBeing there
Being there
 
Doc byyou
Doc byyouDoc byyou
Doc byyou
 
Qualities To Look For In A Recruitment Agency
Qualities To Look For In A Recruitment AgencyQualities To Look For In A Recruitment Agency
Qualities To Look For In A Recruitment Agency
 
Introduction to Enterprise architecture and the steps to perform an Enterpris...
Introduction to Enterprise architecture and the steps to perform an Enterpris...Introduction to Enterprise architecture and the steps to perform an Enterpris...
Introduction to Enterprise architecture and the steps to perform an Enterpris...
 
Maths probability
Maths probabilityMaths probability
Maths probability
 
Factors to Consider Before Switching Your Job
Factors to Consider Before Switching Your JobFactors to Consider Before Switching Your Job
Factors to Consider Before Switching Your Job
 
Things To Avoid At Office
Things To Avoid At OfficeThings To Avoid At Office
Things To Avoid At Office
 
Minerals
MineralsMinerals
Minerals
 
What's Your Element? - Ignite Presentation
What's Your Element? - Ignite PresentationWhat's Your Element? - Ignite Presentation
What's Your Element? - Ignite Presentation
 

Similar a High Voltage - Building Static Sites With Wordpress-Managed Content

Week01 jan19 introductionto_php
Week01 jan19 introductionto_phpWeek01 jan19 introductionto_php
Week01 jan19 introductionto_php
Jeanho Chu
 
Php training in bhubaneswar
Php training in bhubaneswar Php training in bhubaneswar
Php training in bhubaneswar
litbbsr
 
Week01 jan19 introductionto_php
Week01 jan19 introductionto_phpWeek01 jan19 introductionto_php
Week01 jan19 introductionto_php
Jeanho Chu
 
Content Management Systems (CMS) & Wordpress theme development
Content Management Systems (CMS) & Wordpress theme developmentContent Management Systems (CMS) & Wordpress theme development
Content Management Systems (CMS) & Wordpress theme development
Dave Wallace
 

Similar a High Voltage - Building Static Sites With Wordpress-Managed Content (20)

Geek basics
Geek basicsGeek basics
Geek basics
 
Cms & wordpress theme development 2011
Cms & wordpress theme development 2011Cms & wordpress theme development 2011
Cms & wordpress theme development 2011
 
Wordpress intro
Wordpress introWordpress intro
Wordpress intro
 
After the LAMP, it's time to get MEAN
After the LAMP, it's time to get MEANAfter the LAMP, it's time to get MEAN
After the LAMP, it's time to get MEAN
 
Be faster then rabbits
Be faster then rabbitsBe faster then rabbits
Be faster then rabbits
 
Custom Development in SharePoint – What are my options now?
Custom Development in SharePoint – What are my options now?Custom Development in SharePoint – What are my options now?
Custom Development in SharePoint – What are my options now?
 
Week01 jan19 introductionto_php
Week01 jan19 introductionto_phpWeek01 jan19 introductionto_php
Week01 jan19 introductionto_php
 
ECS19 - Vesa Juvonen - SharePoint and Office 365 Development PowerClass
ECS19 - Vesa Juvonen - SharePoint and Office 365 Development PowerClassECS19 - Vesa Juvonen - SharePoint and Office 365 Development PowerClass
ECS19 - Vesa Juvonen - SharePoint and Office 365 Development PowerClass
 
Tech talk php_cms
Tech talk php_cmsTech talk php_cms
Tech talk php_cms
 
Php training in bhubaneswar
Php training in bhubaneswar Php training in bhubaneswar
Php training in bhubaneswar
 
Php training in bhubaneswar
Php training in bhubaneswar Php training in bhubaneswar
Php training in bhubaneswar
 
Web programming
Web programmingWeb programming
Web programming
 
Apache Content Technologies
Apache Content TechnologiesApache Content Technologies
Apache Content Technologies
 
The Characteristics of a Successful SPA
The Characteristics of a Successful SPAThe Characteristics of a Successful SPA
The Characteristics of a Successful SPA
 
Week01 jan19 introductionto_php
Week01 jan19 introductionto_phpWeek01 jan19 introductionto_php
Week01 jan19 introductionto_php
 
Content Management Systems (CMS) & Wordpress theme development
Content Management Systems (CMS) & Wordpress theme developmentContent Management Systems (CMS) & Wordpress theme development
Content Management Systems (CMS) & Wordpress theme development
 
Building Enterprise Grade Front-End Applications with JavaScript Frameworks
Building Enterprise Grade Front-End Applications with JavaScript FrameworksBuilding Enterprise Grade Front-End Applications with JavaScript Frameworks
Building Enterprise Grade Front-End Applications with JavaScript Frameworks
 
Drupal and Apache Stanbol
Drupal and Apache StanbolDrupal and Apache Stanbol
Drupal and Apache Stanbol
 
Emkane RCC wp qs
Emkane RCC wp qsEmkane RCC wp qs
Emkane RCC wp qs
 
BITM3730 11-8.pptx
BITM3730 11-8.pptxBITM3730 11-8.pptx
BITM3730 11-8.pptx
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 

High Voltage - Building Static Sites With Wordpress-Managed Content

  • 1.
  • 2.
  • 3. …there was a time before WordPress
  • 5. Assemble pages by including common components
  • 6. Mix in data from other sources
  • 7. Emerging trends • DRY • Eliminate duplicate content • Separate concerns • Improve productivity
  • 9. They matter too But what about the content authors?
  • 10.
  • 11. Content is a first class citizen
  • 12. Further separation of concerns • Users enter content using a GUI • Programmers create templates that utilize the user-entered content • Web pages generated on demand
  • 14. It’s not • With (pretty much) any CMS: • Wrangling together templates and data is complicated • The process is demanding and involves needless work
  • 15.
  • 16. Most CMS-based websites Writes ReadsExpensiveModerate
  • 17.
  • 18. Some CMS-based websites Writes ReadsCheapModerate
  • 20. “The stack” stacks up HTTP Accelerator (Varnish) Web Server (Apache) Application Server (WordPress/PHP) Database (MySQL) Object Cache (MemCached) File System
  • 21.
  • 23. Do you build a solution for your problem or do you fit your problem into a solution?
  • 24. Build a solution • We have the tools: • Static site generators • Rapid application frameworks • APIs • CMSs / Writing rooms
  • 26.
  • 27. Why static sites • Fast • Secure • Scalable • Simple themes and integrations • Own conventions, languages, and tools • Excellent version control story
  • 28. The generators help! Build HTML JS SVGCSS GIF JPGPNG Source HTML COFFEE SVG TWIG ERB SCSS GIF JPGPNG JSON YAML MD
  • 29. Productivity, performance, security, scalability 
 paid for with slow resource intensive build processes
  • 30. The new reality Writes ReadsCheapExpensive
  • 32. More hosting options open up • Shared hosting • VPS • GitHub Pages (https://pages.github.com/) • Dropbox (https://pages.github.com/) • Google Drive (https://www.google.com/drive/) • Amazon S3 (http://aws.amazon.com/s3/)
  • 33. There are drawbacks • Particularly with the concept of keeping content in flat files • Hard to contribute (knowledge of Git) • Hard to collaborate
  • 34. Writing rooms to the rescue • Contentful (https://www.contentful.com/) • Prismic.io (https://www.prismic.io/) • Pull in data through the API into a static build process
  • 35. Focus Admin interface for content creation and collaboration
  • 36. However… • Subscription services • Potential for vendor lock-in • Lack of mature, open source alternatives
  • 37. WordPress as a pure CMS • WordPress can be used as an alternative to writing rooms like Prismic.io and Contentful • Content authors use WordPress to manage content and collaborate; not to build web sites • Content pulled out of WordPress and injected into static build process
  • 38. WP REST API • Popular plugin that will be integrated into core • Provides an HTTP REST API • Extensive API for CRUD operations on comments, media, meta data, posts, taxonomies, and users • http://wp-api.org
  • 39. Advanced Custom Fields Pro • Popular plugin that allows for rapid creation of custom fields • Supports many field types, including text, number, image, map, links, and post references • Rich ecosystem of extensions including repeaters • http://www.advancedcustomfields.com
  • 40. WP REST API Custom Fields • Adds custom fields defined with ACF Pro to JSON output • Inserts an object into the meta key with all your fields • http://wordpress.org/plugins/wp-rest-api-custom-fields
  • 41. Putting the backend together • A 15-minute REST server with multi-user support, roles and permissions, and an admin interface 1. Enable the aforementioned plugins 2. Setup friendly permalinks 3. Create custom post types if necessary 4. Setup custom fields if necessary 5. API accessible at /wp-json
  • 42.
  • 43. Choosing a static site generator • Comes in pretty much any language: C, C++, Java, Go, Haskell, Erlang, JavaScript, Ruby, Python, PHP, etc. • Choose a language you a comfortable with and enjoy working with • Choose a system that is mature • Choose a system that lets you work with many different types of inputs, including remote content for maximum flexibility
  • 45. Key Features • HTML, Markdown, YAML, and JSON format • Templating language • Asset pipeline • Live reload • Development server • Common preprocessors and concat/minify out of the box
  • 46. Useful Extensions • Deploy • Blog • Pagination • SVG Fallback • Full list: https://directory.middlemanapp.com/#/extensions/all
  • 47. Directory Structure • Data • Lib • Source • Images • Javascripts • Layouts • Stylesheets • Pages, posts, etc
  • 48. Source index.html.md /about Build Data /css /js/img layout.html.erb logo.svg all.scss _header.scss _footer.scss all.js menu.coffee feed.js _header.html.erb /layouts
  • 49. Build index.html /about /css /js/img logo.svg all.css all.js logo.png logo@2x.png
  • 50. Dynamic Files • Data is made available to our templates • Useful for creating menus, lists, directories, etc. • Pages can also be dynamically generated from data
  • 51. sally.html roger.html sue.html steven.html lisa.html people build people.json data
  • 52. Dynamic Pages In config.rb people.each do |person| proxy “people/#{person[‘name’]}.html”, “layout/person.html”, locals: { person: person } end
  • 53. Data Source Library In lib/wordpress.rb class WordPress include HTTParty def initialize(uri) self.class.base_uri uri end def posts @posts ||= self.class.get(‘/posts?type=post’) end end
  • 54. Dynamic Pages from Data Source In config.rb @wordpress = WordPress.new(“http://supersecret.dev/wp-json”) @wordpress.posts.each do |post| proxy “/blog/#{post[‘slug’]}/index.html”, “templates/post.html”, locals: { post: post } end
  • 55. Expose Data Source to Templates In config.rb helpers do def wordpress @wordpress end end
  • 56. Use Data Source in Templates In source/blog/index.html <% wordpress.posts.each do |post| %> <div> <h3><a href=“/blog/<%= post[‘slug’] %>/”><%= post[‘title’] %></a></h3> <div><%= post[‘excerpt’] %></div> </div> <% end %>
  • 57. Nicer than this! <?php
 if (have_posts()) {
 while ( have_posts()) { 
 the_post();
 ?>
 <div>
 <h3><a href=“<?php the_permalink(); ?>”><?php the_title(); ?></a></h3>
 <div><?php the_excerpt(); ?></div>
 </div>
 <?php 
 }
 }
 ?>
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63. There’s a plugin for that • Hookpress • Turns internal hooks into web hooks • Recompile your site when content is updated • https://wordpress.org/plugins/hookpress/