title: Stay Static - Build Static Websites w/ VuePress (and Text with Formatting Conventions in Markdown)
The Biggies (PHP Rules!)
- WordPress
- Drupal
- Joomla!
On your live production site requires
- database (e.g. mysql)
- application server (e.g. mod_php)
- web server (e.g. apache)
On every request - (re)builds the page on-the-fly e.g. queries the database, runs scripts, merges templates, etc.
- When a visitor first clicks on or types a URL for a page that is part of your blog, WordPress starts by running a few core files (wp-config.php, wp-settings.php, etc.) If you are interested in the specifics of the file loading order, start at index.php and follow the chain of files as each PHP file includes/requires additional PHP files (or read this excellent post at humanshell.net)
- WordPress loads and initializes any plugins you have activated (calls the plugin init actions).
- WordPress loads the "text domain" for internationalization, and the functions.php file from the currently active theme.
- WordPress runs the wp() function (in wp-includes/functions.php), which calls $wp->main() ($wp is an object of class WP, which is defined in wp-includes/class-wp.php). This tells WordPress to:
- Parse the URL into a query specification using WP->parse_request() -- more on that below.
- Set all the is_ variables that are used by Conditional Tags using $wp_query->parse_query() ($wp_query is an object of class WP_Query, which is defined in wp-includes/query.php). Note that in spite of this function's name, in this case WP_Query->parse_query doesn't actually do any parsing for us, since that is done before-hand by WP->parse_request().
- Convert the query specification into a MySQL database query, and run the database query to get the list of posts, in function WP_Query->get_posts(). Save the posts in the $wp_query object to be used in the WordPress Loop.
- Handle 404 errors.
- Send the blog's HTTP headers.
- Set up some variables for the WordPress Loop.
- WordPress loads your template, figures out which template file to use according to the Template Hierarchy, and runs that file (basically doing whatever your template file says to do). Or, WordPress could run one of the feed files (such as wp-rss2.php) instead.
- Generally, the template or feed file runs the WordPress Loop to print blog posts or a static page.
- The template or feed file will also likely print out permalinks to some archives, categories, or posts using built-in WordPress functions.
And so and so on and so on and so on.
(Source: codex.wordpress.org/Query_Overview)
The Biggies (PHP Rules!)
- WordPress
- Drupal
- Joomla!
See the difference ;-) JavaScript Fatigue - Anyone? Use WordPress (PHP) ;-) about 30% of the Internet and counting.
The Biggies in 1999
- Macromedia Dreamweaver
- Microsoft FrontPage
- Netscape Composer
And today?
by Kyle Mathews et al (★22 649) -
github: gatsbyjs/gatsby
(Source: gatsbyjs.org)
And for Vue?
by Evan You et al (★7 741) -
github: vuejs/vuepress
(Source: vuepress.vuejs.org)
April 2018 - First Version (0.1) by Evan You.
(Source: vuepress/CHANGELOG.md)
- Nuxt
- Docsify / Docute
- Hexo
- GitBook
A: See VuePress Guide Why Not ...?
$ yarn global add vuepress # -or- npm install -g vuepress
$ echo '# Hello VuePress Vienna' > README.md
$ vuepress dev # dev server with hot reloading
$ vuepress build
Try:
$ vuepress -h
prints
Usage: vuepress <command> [options]
Options:
-V, --version output the version number
-h, --help output usage information
Commands:
dev [options] [targetDir] start development server
build [options] [targetDir] build dir as static site
eject [targetDir] copy the default theme into .vuepress/theme for customization.
Run vuepress <command> --help for detailed usage of given command.
and
$ vuepress dev -h
prints
Usage: dev [options] [targetDir]
start development server
Options:
-p, --port <port> use specified port (default: 8080)
-h, --host <host> use specified host (default: 0.0.0.0)
-h, --help output usage information
and
$ vuepress build -h
prints
Usage: build [options] [targetDir]
build dir as static site
Options:
-d, --dest <outDir> specify build output dir (default: .vuepress/dist)
--debug build in development mode for debugging
-h, --help output usage information
$ yarn add -D vuepress
$ mkdir docs
$ echo '# Hello VuePress Vienna' > docs/README.md
Then, add some scripts to package.json:
{
"scripts": {
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs"
}
}
Now you can start writing with:
$ yarn docs:dev
To build / generate the (static) website run:
$ yarn docs:build
└──docs/
Page-1.md
Page-2.md
README.md
└──docs/
│ Page-1.md
│ Page-2.md
│ README.md
└──.vuepress/
config.js
config.js
:
module.exports = {
title: 'My VuePress Site',
themeConfig: {
sidebar: [
'/',
'/Page-1',
'/Page-2'
]
}
};
└── docs/
│ Page-1.md
│ Page-2.md
│ README.md
│
└── .vuepress/
│ config.js
└── components/
NumberModifier.vue
NumberModifier.vue
:
<template>
<div class="number-modifier">
<button @click="increment()">+</button>
<strong> {{value}} </strong>
<button @click="decrement()">-</button>
</div>
</template>
<script>
export default {
props: ['start'],
data() {
return {
value: this.start
}
},
methods: {
increment() { this.value++ },
decrement() { this.value-- }
}
}
</script>
Page-1.md
:
---
title: Page 1
# We can even add meta tags to the page! This sets the keywords meta tag.
# <meta name="keywords" content="my SEO keywords"/>
meta:
- name: keywords
- content: my SEO keywords
---
# This is Page 1
**Our Component:**
<NumberModifier :start="5"></NumberModifier>
Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
README.md
:
# Hello VuePress!
_How are you doing?_
> **I'm doing fine, thanks!**
_Great, I was wondering what `49 + 32` is?_
> **{{49 + 32}}**
_Could you repeat that a few times?_
> **Sigh...**
<p v-for="i of 3">{{49 + 32}}</p>
$ yarn docs:build
Results in:
└───dist
│ 404.html
│ index.html
│ Page-1.html
│ Page-2.html
│
└───assets
├───css
│ 4.styles.b3ee96ce.css
│
├───img
│ search.83621669.svg
│
└───js
0.cef95dbc.js
1.b6288c2e.js
2.e793cd69.js
3.70a93ea8.js
app.2afab76e.js
Use default (built-in) theme as a start:
└───theme
│ DropdownLink.vue
│ Home.vue
│ Layout.vue
│ Navbar.vue
│ NavLink.vue
│ NavLinks.vue
│ NotFound.vue
│ OutboundLink.vue
│ Page.vue
│ search.svg
│ SearchBox.vue
│ Sidebar.vue
│ SidebarButton.vue
│ SidebarGroup.vue
│ SidebarLink.vue
│ util.js
│
└───styles
arrow.styl
code.styl
config.styl
custom-blocks.styl
mobile.styl
nprogress.styl
theme.styl
Home.vue
:
<template>
<div class="home">
<div class="hero">
<img v-if="data.heroImage" :src="$withBase(data.heroImage)" alt="hero">
<h1>{{ data.heroText || $title }}</h1>
<p class="description">
{{ data.tagline || $description }}
</p>
<p class="action" v-if="data.actionText && data.actionLink">
<NavLink class="action-button" :item="actionLink"/>
</p>
</div>
<div class="features" v-if="data.features && data.features.length">
<div class="feature" v-for="feature in data.features">
<h2>{{ feature.title }}</h2>
<p>{{ feature.details }}</p>
</div>
</div>
<Content custom/>
<div class="footer" v-if="data.footer">
{{ data.footer }}
</div>
</div>
</template>
<script>
import NavLink from './NavLink.vue'
export default {
components: { NavLink },
computed: {
data () {
return this.$page.frontmatter
},
actionLink () {
return {
link: this.data.actionLink,
text: this.data.actionText
}
}
}
}
</script>