{{ block "title" . }}{{ .Site.Title }}{{ end }}
6 | {{- partial "head.html" . -}}
7 |
8 |
9 | {{- block "main" . }}{{- end }}
10 |
11 | {{- partial "js.html" . -}}
12 |
13 |
14 |
--------------------------------------------------------------------------------
/exampleSite/content/about.md:
--------------------------------------------------------------------------------
1 | +++
2 | title = "About Hugo"
3 | date = "2014-04-09"
4 | menu = "main"
5 | +++
6 |
7 | Hugo is the **world’s fastest framework for building websites**. It is written in Go.
8 |
9 | It makes use of a variety of open source projects including:
10 |
11 | * https://github.com/russross/blackfriday
12 | * https://github.com/alecthomas/chroma
13 | * https://github.com/muesli/smartcrop
14 | * https://github.com/spf13/cobra
15 | * https://github.com/spf13/viper
16 |
17 | Learn more and contribute on [GitHub](https://github.com/gohugoio).
18 |
19 |
--------------------------------------------------------------------------------
/theme.toml:
--------------------------------------------------------------------------------
1 | # theme.toml template for a Hugo theme
2 | # See https://github.com/gohugoio/hugoThemes#themetoml for an example
3 |
4 | name = "Bootstrap-BP-Startpage"
5 | license = "MIT"
6 | licenselink = "https://github.com/spech66/bootstrap-bp-hugo-startpage/blob/master/LICENSE"
7 | description = "Bootstrap based Hugo startpage theme which provides out of the box best practices."
8 | homepage = "https://github.com/spech66/bootstrap-bp-hugo-startpage/"
9 | tags = ["minimalist", "single-page", "clean", "simple", "bootstrap", "responsive", "one-page", "light", "fast"]
10 | features = ["responsive", "bootstrap v4.1.x", "open graph", "twitter cards"]
11 | min_version = "0.48.0"
12 |
13 | [author]
14 | name = "Sebastian Pech"
15 | homepage = "https://www.spech.de/"
16 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | custom: https://www.paypal.me/SPech/5 # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
13 |
--------------------------------------------------------------------------------
/exampleSite/data/links.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - group: Social media
3 | items:
4 | - title: reddit
5 | url: https://www.reddit.com
6 | icon: fab fa-reddit
7 | - title: Facebook
8 | url: https://www.facebook.com
9 | icon: fab fa-facebook
10 | - title: Instagram
11 | url: https://www.instagram.com
12 | icon: fab fa-instagram
13 | - title: Spotify
14 | url: https://www.spotify.com
15 | icon: fab fa-spotify
16 | - title: SPech.de Blog
17 | url: https://www.spech.de
18 | icon: fas fa-blog
19 | - group: Utilities
20 | items:
21 | - title: Confluence
22 | url: https://www.atlassian.com/software/confluence
23 | icon: fab fa-confluence
24 | - title: D&D
25 | url: https://dnd.wizards.com/
26 | icon: fab fa-d-and-d
27 | - title: GitHub
28 | url: https://github.com/spech66/
29 | icon: fab fa-github
30 | - title: Medium
31 | url: https://www.medium.com
32 | icon: fab fa-medium
33 | - title: Amazon
34 | url: https://www.amazon.de
35 | icon: fab fa-amazon
36 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Sebastian Pech
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Sebastian Pech
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/layouts/partials/head.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 | {{ template "_internal/schema.html" . }}
10 | {{ template "_internal/opengraph.html" . }}
11 | {{ template "_internal/twitter_cards.html" . }}
12 |
13 | {{ with .OutputFormats.Get "RSS" }}{{ end }}
14 |
15 | {{ $cssbootstrap := resources.Get "/css/bootstrap.min.css" }}
16 | {{ $cssfontawesome := resources.Get "/css/fontawesome.min.css" }}
17 | {{ $cssmain := resources.Get "/css/main.css" }}
18 | {{ $allcss := slice $cssbootstrap $cssfontawesome $cssmain | resources.Concat "/css/vendor.css" | minify | fingerprint }}
19 |
20 |
--------------------------------------------------------------------------------
/layouts/partials/seo_schema.html:
--------------------------------------------------------------------------------
1 |
29 |
--------------------------------------------------------------------------------
/exampleSite/config.toml:
--------------------------------------------------------------------------------
1 | ignoreFiles = ["content/portfolio/\\.*","content/product/\\.*","content/sketch/\\.*","content/homepage/\\.*","content/post/\\.*","content/\\.*"] # disable example pages as this is a single page
2 | baseURL = "https://example.com/"
3 | languageCode = "en-US"
4 | title = "Bootstrap-BP hugo startpage"
5 | theme = "bootstrap-bp-hugo-startpage"
6 | copyright = "Sebastian Pech"
7 | enableRobotsTXT = true
8 | pygmentsCodeFences = true
9 | canonifyurls = true
10 |
11 | [pagination]
12 | pagerSize = 5
13 |
14 | [sitemap]
15 | changefreq = "weekly"
16 | priority = 0.5
17 |
18 | [permalinks]
19 | posts = "/:year/:month/:slug/"
20 | post = "/:year/:month/:slug/"
21 | pages = "/:slug/"
22 | page = "/:slug/"
23 |
24 | [params.author]
25 | name = "Sebastian Pech"
26 |
27 | [params]
28 | description = "Text about the site"
29 | #images = ["logo.jpg"]
30 | startPageColumns = true
31 | welcomeText = "Bootstrap-BP hugo startpage"
32 |
33 | [[params.searchEngines]]
34 | name = "Google"
35 | activated = true
36 | url = "https://www.google.com/search"
37 |
38 | [[params.searchEngines]]
39 | name = "DuckDuckGo"
40 | activated = true
41 | url = "https://duckduckgo.com/"
42 |
43 | [[params.searchEngines]]
44 | name = "Bing"
45 | activated = true
46 | url = "https://www.bing.com/search"
47 |
48 | [[params.searchEngines]]
49 | name = "Baidu"
50 | activated = true
51 | url = "https://baidu.com/s"
52 | searchkey = "wd"
53 |
54 | [taxonomies]
55 |
--------------------------------------------------------------------------------
/static/FONTAWESOME-LICENSE.txt:
--------------------------------------------------------------------------------
1 | Font Awesome Free License
2 | -------------------------
3 |
4 | Font Awesome Free is free, open source, and GPL friendly. You can use it for
5 | commercial projects, open source projects, or really almost whatever you want.
6 | Full Font Awesome Free license: https://fontawesome.com/license/free.
7 |
8 | # Icons: CC BY 4.0 License (https://creativecommons.org/licenses/by/4.0/)
9 | In the Font Awesome Free download, the CC BY 4.0 license applies to all icons
10 | packaged as SVG and JS file types.
11 |
12 | # Fonts: SIL OFL 1.1 License (https://scripts.sil.org/OFL)
13 | In the Font Awesome Free download, the SIL OFL license applies to all icons
14 | packaged as web and desktop font files.
15 |
16 | # Code: MIT License (https://opensource.org/licenses/MIT)
17 | In the Font Awesome Free download, the MIT license applies to all non-font and
18 | non-icon files.
19 |
20 | # Attribution
21 | Attribution is required by MIT, SIL OFL, and CC BY licenses. Downloaded Font
22 | Awesome Free files already contain embedded comments with sufficient
23 | attribution, so you shouldn't need to do anything additional when using these
24 | files normally.
25 |
26 | We've kept attribution comments terse, so we ask that you do not actively work
27 | to remove them from files, especially code. They're a great way for folks to
28 | learn about Font Awesome.
29 |
30 | # Brand Icons
31 | All brand icons are trademarks of their respective owners. The use of these
32 | trademarks does not indicate endorsement of the trademark holder by Font
33 | Awesome, nor vice versa. **Please do not use brand logos for any purpose except
34 | to represent the company, product, or service to which they refer.**
35 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | lerna-debug.log*
8 |
9 | # Diagnostic reports (https://nodejs.org/api/report.html)
10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11 |
12 | # Runtime data
13 | pids
14 | *.pid
15 | *.seed
16 | *.pid.lock
17 |
18 | # Directory for instrumented libs generated by jscoverage/JSCover
19 | lib-cov
20 |
21 | # Coverage directory used by tools like istanbul
22 | coverage
23 | *.lcov
24 |
25 | # nyc test coverage
26 | .nyc_output
27 |
28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29 | .grunt
30 |
31 | # Bower dependency directory (https://bower.io/)
32 | bower_components
33 |
34 | # node-waf configuration
35 | .lock-wscript
36 |
37 | # Compiled binary addons (https://nodejs.org/api/addons.html)
38 | build/Release
39 |
40 | # Dependency directories
41 | node_modules/
42 | jspm_packages/
43 |
44 | # TypeScript v1 declaration files
45 | typings/
46 |
47 | # TypeScript cache
48 | *.tsbuildinfo
49 |
50 | # Optional npm cache directory
51 | .npm
52 |
53 | # Optional eslint cache
54 | .eslintcache
55 |
56 | # Microbundle cache
57 | .rpt2_cache/
58 | .rts2_cache_cjs/
59 | .rts2_cache_es/
60 | .rts2_cache_umd/
61 |
62 | # Optional REPL history
63 | .node_repl_history
64 |
65 | # Output of 'npm pack'
66 | *.tgz
67 |
68 | # Yarn Integrity file
69 | .yarn-integrity
70 |
71 | # dotenv environment variables file
72 | .env
73 | .env.test
74 |
75 | # parcel-bundler cache (https://parceljs.org/)
76 | .cache
77 |
78 | # Next.js build output
79 | .next
80 |
81 | # Nuxt.js build / generate output
82 | .nuxt
83 | dist
84 |
85 | # Gatsby files
86 | .cache/
87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js
88 | # https://nextjs.org/blog/next-9-1#public-directory-support
89 | # public
90 |
91 | # vuepress build output
92 | .vuepress/dist
93 |
94 | # Serverless directories
95 | .serverless/
96 |
97 | # FuseBox cache
98 | .fusebox/
99 |
100 | # DynamoDB Local files
101 | .dynamodb/
102 |
103 | # TernJS port file
104 | .tern-port
105 |
--------------------------------------------------------------------------------
/layouts/index.html:
--------------------------------------------------------------------------------
1 | {{ define "main" }}
2 |
3 |
{{ .Site.Params.welcomeText }}
4 |
5 | {{ if .Site.Params.searchEngines }}
6 | {{ range .Site.Params.searchEngines }}
7 | {{ if .activated }}
8 |
11 | {{ end }}
12 | {{ end }}
13 | {{ end }}
14 |
15 | {{ if .Site.Params.startPageColumns }}
16 |
43 | {{ end }}
44 |
45 | {{ end }}
46 |
--------------------------------------------------------------------------------
/exampleSite/content/post/hugoisforlovers.md:
--------------------------------------------------------------------------------
1 | +++
2 | title = "Getting Started with Hugo"
3 | description = ""
4 | tags = [
5 | "go",
6 | "golang",
7 | "hugo",
8 | "development",
9 | ]
10 | date = "2014-04-02"
11 | categories = [
12 | "Development",
13 | "golang",
14 | ]
15 | menu = "main"
16 | +++
17 |
18 | ## Step 1. Install Hugo
19 |
20 | Go to [Hugo releases](https://github.com/spf13/hugo/releases) and download the
21 | appropriate version for your OS and architecture.
22 |
23 | Save it somewhere specific as we will be using it in the next step.
24 |
25 | More complete instructions are available at [Install Hugo](https://gohugo.io/getting-started/installing/)
26 |
27 | ## Step 2. Build the Docs
28 |
29 | Hugo has its own example site which happens to also be the documentation site
30 | you are reading right now.
31 |
32 | Follow the following steps:
33 |
34 | 1. Clone the [Hugo repository](http://github.com/spf13/hugo)
35 | 2. Go into the repo
36 | 3. Run hugo in server mode and build the docs
37 | 4. Open your browser to http://localhost:1313
38 |
39 | Corresponding pseudo commands:
40 |
41 | git clone https://github.com/spf13/hugo
42 | cd hugo
43 | /path/to/where/you/installed/hugo server --source=./docs
44 | > 29 pages created
45 | > 0 tags index created
46 | > in 27 ms
47 | > Web Server is available at http://localhost:1313
48 | > Press ctrl+c to stop
49 |
50 | Once you've gotten here, follow along the rest of this page on your local build.
51 |
52 | ## Step 3. Change the docs site
53 |
54 | Stop the Hugo process by hitting Ctrl+C.
55 |
56 | Now we are going to run hugo again, but this time with hugo in watch mode.
57 |
58 | /path/to/hugo/from/step/1/hugo server --source=./docs --watch
59 | > 29 pages created
60 | > 0 tags index created
61 | > in 27 ms
62 | > Web Server is available at http://localhost:1313
63 | > Watching for changes in /Users/spf13/Code/hugo/docs/content
64 | > Press ctrl+c to stop
65 |
66 |
67 | Open your [favorite editor](http://vim.spf13.com) and change one of the source
68 | content pages. How about changing this very file to *fix the typo*. How about changing this very file to *fix the typo*.
69 |
70 | Content files are found in `docs/content/`. Unless otherwise specified, files
71 | are located at the same relative location as the url, in our case
72 | `docs/content/overview/quickstart.md`.
73 |
74 | Change and save this file.. Notice what happened in your terminal.
75 |
76 | > Change detected, rebuilding site
77 |
78 | > 29 pages created
79 | > 0 tags index created
80 | > in 26 ms
81 |
82 | Refresh the browser and observe that the typo is now fixed.
83 |
84 | Notice how quick that was. Try to refresh the site before it's finished building. I double dare you.
85 | Having nearly instant feedback enables you to have your creativity flow without waiting for long builds.
86 |
87 | ## Step 4. Have fun
88 |
89 | The best way to learn something is to play with it.
90 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Bootstrap-BP hugo startpage
2 |
3 | Bootstrap based Hugo startpage theme which provides out of the box best practices.
4 | This theme is a combination of my [Bootstrap-BP hugo theme](https://github.com/spech66/bootstrap-bp-hugo-theme) and my [startpage](https://github.com/spech66/startpage).
5 | Instead of rendering the items on-the-fly as in the startpage theme the **Bootstrap-BP hugo startpage** will generate a complete single page site.
6 |
7 | Other themes by Sebastian Pech: [Bootstrap-BP](https://github.com/spech66/bootstrap-bp-hugo-theme), [Materialize-BP](https://github.com/spech66/materialize-bp-hugo-theme),
8 | [Bootstrap-BP hugo startpage](https://github.com/spech66/bootstrap-bp-hugo-startpage).
9 |
10 | ## Install the theme
11 |
12 | With Git installed, run the following commands inside the Hugo site folder. If Hugo has not yet been installed, read the setup guide [here](https://gohugo.io/getting-started/quick-start/).
13 |
14 | ```sh
15 | mkdir themes
16 | cd themes
17 | git clone https://github.com/spech66/bootstrap-bp-hugo-startpage.git
18 | ```
19 |
20 | You can get a zip of the latest version of the theme from the [home page](https://github.com/spech66/bootstrap-bp-hugo-theme) and extract it to the themes folder.
21 |
22 | ## Theme settings
23 |
24 | Most settings should be done with hugo specific variables. There are only a few (optional) additional `[params]`.
25 |
26 | * `welcomeText = "Startpage!"` is the text above the search box
27 | * `startPageColumns = true` will show the start page in grouped lists
28 |
29 | Activate the search engine you want to use (or add a new one).
30 |
31 | ```toml
32 | [[params.searchEngines]]
33 | name = "Google"
34 | activated = true
35 | url = "https://www.google.com/search"
36 |
37 | [[params.searchEngines]]
38 | name = "DuckDuckGo"
39 | activated = true
40 | url = "https://duckduckgo.com/"
41 |
42 | [[params.searchEngines]]
43 | name = "Bing"
44 | activated = true
45 | url = "https://www.bing.com/search"
46 |
47 | [[params.searchEngines]]
48 | name = "Baidu"
49 | activated = true
50 | url = "https://baidu.com/"
51 | searchkey = "kw"
52 | ```
53 |
54 | 
55 |
56 | 
57 |
58 | Define the links in a file in `data/links.yml`. This needs to be structured like this.
59 |
60 | ```yml
61 | ---
62 | - group: Social media
63 | items:
64 | - title: reddit
65 | url: https://www.reddit.com
66 | icon: fab fa-reddit
67 | - title: Facebook
68 | url: https://www.facebook.com
69 | icon: fab fa-facebook
70 | - group: Utilities
71 | items:
72 | - title: GitHub
73 | url: https://www.github.com
74 | icon: fab fa-github
75 | ```
76 |
77 | Icons are taken from [Font Awesome](https://fontawesome.com/icons?d=gallery).
78 |
79 | ## Sources
80 |
81 | * Background image by [Mikael Gustafsson](https://www.artstation.com/artwork/Y2Wew)
82 |
83 | Inspired by:
84 |
85 | * [Reddit - r/startpages](https://www.reddit.com/r/startpages/)
86 | * [Github - 0-Tikaro - Minimum Viable Startpage](https://github.com/0-Tikaro/minimum-viable-startpage), Searchbox code
87 | * [Github - ViktorKare - startpage](https://github.com/ViktorKare/startpage)
88 |
--------------------------------------------------------------------------------
/exampleSite/content/post/migrate-from-jekyll.md:
--------------------------------------------------------------------------------
1 | ---
2 | date: 2014-03-10
3 | linktitle: Migrating from Jekyll
4 | menu:
5 | main:
6 | parent: tutorials
7 | prev: /tutorials/mathjax
8 | title: Migrate to Hugo from Jekyll
9 | weight: 10
10 | ---
11 |
12 | ## Move static content to `static`
13 | Jekyll has a rule that any directory not starting with `_` will be copied as-is to the `_site` output. Hugo keeps all static content under `static`. You should therefore move it all there.
14 | With Jekyll, something that looked like
15 |
16 | ▾ /
17 | ▾ images/
18 | logo.png
19 |
20 | should become
21 |
22 | ▾ /
23 | ▾ static/
24 | ▾ images/
25 | logo.png
26 |
27 | Additionally, you'll want any files that should reside at the root (such as `CNAME`) to be moved to `static`.
28 |
29 | ## Create your Hugo configuration file
30 | Hugo can read your configuration as JSON, YAML or TOML. Hugo supports parameters custom configuration too. Refer to the [Hugo configuration documentation](/overview/configuration/) for details.
31 |
32 | ## Set your configuration publish folder to `_site`
33 | The default is for Jekyll to publish to `_site` and for Hugo to publish to `public`. If, like me, you have [`_site` mapped to a git submodule on the `gh-pages` branch](http://blog.blindgaenger.net/generate_github_pages_in_a_submodule.html), you'll want to do one of two alternatives:
34 |
35 | 1. Change your submodule to point to map `gh-pages` to public instead of `_site` (recommended).
36 |
37 | git submodule deinit _site
38 | git rm _site
39 | git submodule add -b gh-pages git@github.com:your-username/your-repo.git public
40 |
41 | 2. Or, change the Hugo configuration to use `_site` instead of `public`.
42 |
43 | {
44 | ..
45 | "publishdir": "_site",
46 | ..
47 | }
48 |
49 | ## Convert Jekyll templates to Hugo templates
50 | That's the bulk of the work right here. The documentation is your friend. You should refer to [Jekyll's template documentation](http://jekyllrb.com/docs/templates/) if you need to refresh your memory on how you built your blog and [Hugo's template](/layout/templates/) to learn Hugo's way.
51 |
52 | As a single reference data point, converting my templates for [heyitsalex.net](http://heyitsalex.net/) took me no more than a few hours.
53 |
54 | ## Convert Jekyll plugins to Hugo shortcodes
55 | Jekyll has [plugins](http://jekyllrb.com/docs/plugins/); Hugo has [shortcodes](/doc/shortcodes/). It's fairly trivial to do a port.
56 |
57 | ### Implementation
58 | As an example, I was using a custom [`image_tag`](https://github.com/alexandre-normand/alexandre-normand/blob/74bb12036a71334fdb7dba84e073382fc06908ec/_plugins/image_tag.rb) plugin to generate figures with caption when running Jekyll. As I read about shortcodes, I found Hugo had a nice built-in shortcode that does exactly the same thing.
59 |
60 | Jekyll's plugin:
61 |
62 | module Jekyll
63 | class ImageTag < Liquid::Tag
64 | @url = nil
65 | @caption = nil
66 | @class = nil
67 | @link = nil
68 | // Patterns
69 | IMAGE_URL_WITH_CLASS_AND_CAPTION =
70 | IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK = /(\w+)(\s+)((https?:\/\/|\/)(\S+))(\s+)"(.*?)"(\s+)->((https?:\/\/|\/)(\S+))(\s*)/i
71 | IMAGE_URL_WITH_CAPTION = /((https?:\/\/|\/)(\S+))(\s+)"(.*?)"/i
72 | IMAGE_URL_WITH_CLASS = /(\w+)(\s+)((https?:\/\/|\/)(\S+))/i
73 | IMAGE_URL = /((https?:\/\/|\/)(\S+))/i
74 | def initialize(tag_name, markup, tokens)
75 | super
76 | if markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK
77 | @class = $1
78 | @url = $3
79 | @caption = $7
80 | @link = $9
81 | elsif markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION
82 | @class = $1
83 | @url = $3
84 | @caption = $7
85 | elsif markup =~ IMAGE_URL_WITH_CAPTION
86 | @url = $1
87 | @caption = $5
88 | elsif markup =~ IMAGE_URL_WITH_CLASS
89 | @class = $1
90 | @url = $3
91 | elsif markup =~ IMAGE_URL
92 | @url = $1
93 | end
94 | end
95 | def render(context)
96 | if @class
97 | source = ""
98 | else
99 | source = ""
100 | end
101 | if @link
102 | source += ""
103 | end
104 | source += ""
105 | if @link
106 | source += ""
107 | end
108 | source += "#{@caption}" if @caption
109 | source += ""
110 | source
111 | end
112 | end
113 | end
114 | Liquid::Template.register_tag('image', Jekyll::ImageTag)
115 |
116 | is written as this Hugo shortcode:
117 |
118 |
119 |
120 | {{ with .Get "link"}}{{ end }}
121 |
122 | {{ if .Get "link"}}{{ end }}
123 | {{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
124 | {{ if isset .Params "title" }}
125 | {{ .Get "title" }}{{ end }}
126 | {{ if or (.Get "caption") (.Get "attr")}}
{{ end }}
132 |
133 | {{ end }}
134 |
135 |
136 |
137 | ### Usage
138 | I simply changed:
139 |
140 | {% image full http://farm5.staticflickr.com/4136/4829260124_57712e570a_o_d.jpg "One of my favorite touristy-type photos. I secretly waited for the good light while we were "having fun" and took this. Only regret: a stupid pole in the top-left corner of the frame I had to clumsily get rid of at post-processing." ->http://www.flickr.com/photos/alexnormand/4829260124/in/set-72157624547713078/ %}
141 |
142 | to this (this example uses a slightly extended version named `fig`, different than the built-in `figure`):
143 |
144 | {{%/* fig class="full" src="http://farm5.staticflickr.com/4136/4829260124_57712e570a_o_d.jpg" title="One of my favorite touristy-type photos. I secretly waited for the good light while we were having fun and took this. Only regret: a stupid pole in the top-left corner of the frame I had to clumsily get rid of at post-processing." link="http://www.flickr.com/photos/alexnormand/4829260124/in/set-72157624547713078/" */%}}
145 |
146 | As a bonus, the shortcode named parameters are, arguably, more readable.
147 |
148 | ## Finishing touches
149 | ### Fix content
150 | Depending on the amount of customization that was done with each post with Jekyll, this step will require more or less effort. There are no hard and fast rules here except that `hugo server --watch` is your friend. Test your changes and fix errors as needed.
151 |
152 | ### Clean up
153 | You'll want to remove the Jekyll configuration at this point. If you have anything else that isn't used, delete it.
154 |
155 | ## A practical example in a diff
156 | [Hey, it's Alex](http://heyitsalex.net/) was migrated in less than a _father-with-kids day_ from Jekyll to Hugo. You can see all the changes (and screw-ups) by looking at this [diff](https://github.com/alexandre-normand/alexandre-normand/compare/869d69435bd2665c3fbf5b5c78d4c22759d7613a...b7f6605b1265e83b4b81495423294208cc74d610).
157 |
--------------------------------------------------------------------------------
/static/.htaccess:
--------------------------------------------------------------------------------
1 | RewriteEngine On
2 |
3 | # If you migrate from wordpress this will keep your tags and categories working
4 | # RewriteRule ^tag/(.*)$ https://www.REPLACEME.xyz/tags/$1/ [R=301,L]
5 | # RewriteRule ^category/(.*)$ https://www.REPLACEME.xyz/categories/$1/ [R=301,L]
6 |
7 | # Migrate old content
8 | # RewriteRule ^my/old/(.*)$ https://www.REPLACEME.xyz/new/page/ [R=301,L]
9 | # RewriteRule ^2018/10/old-blog-post/(.*)$ https://www.REPLACEME.xyz/2018/10/new-blog-post/ [R=301,L]
10 |
11 | # SSL and www
12 | # RewriteCond %{HTTPS} !on [OR]
13 | # RewriteCond %{HTTP_HOST} !^www\.
14 | # RewriteRule (.*) https://www.REPLACEME.xyz%{REQUEST_URI} [L,R=301]
15 |
16 | # Create 404 error page in /layouts
17 | ErrorDocument 404 /404.html
18 |
19 | # Redirect Wordpress RSS feed URL to Hugo RSS feed URL
20 | # RedirectMatch 301 (?i)^/feed/?(index.xml)?$ https://www.REPLACEME.xyz/index.xml
21 |
22 | # HSTS
23 | Header set Strict-Transport-Security "max-age=31536000"
24 | # Block site from being framed with X-Frame-Options and CSP
25 | #Header set Content-Security-Policy "frame-ancestors 'self';"
26 | Header append X-Frame-Options: DENY
27 | # Prevent browsers from incorrectly detecting non-scripts as scripts
28 | Header append X-Content-Type-Options: nosniff
29 | # Content Security Policy
30 | # Don't implement the above policy yet; instead just report violations that would have occured
31 | #Header set Content-Security-Policy-Report-Only: "default-src https: 'unsafe-eval' 'unsafe-inline' data:; img-src * data:; object-src 'none'; frame-src 'self' *.google.de google.de *.google.com google.com; font-src * https: data:; frame-ancestors 'self';"
32 | Header set Content-Security-Policy: "default-src https: 'unsafe-eval' 'unsafe-inline' data:; img-src * data:; object-src 'none'; frame-src 'self' *.google.de google.de *.google.com google.com; font-src * data:; frame-ancestors 'self';"
33 |
34 | # Active GZIP compression
35 |
36 | SetOutputFilter DEFLATE
37 |
38 |
39 |
40 | Header append Cache-Control "public"
41 | Header append Vary Accept-Encoding
42 | Header set Connection keep-alive
43 | Header unset ETag
44 | FileETag None
45 |
46 | # Because `mod_headers` cannot match based on the content-type,
47 | # the following workaround needs to be used.
48 |
49 | Header unset Content-Security-Policy
50 | Header unset X-Content-Security-Policy
51 | Header unset X-Frame-Options
52 | Header unset X-UA-Compatible
53 | Header unset X-WebKit-CSP
54 | Header unset X-XSS-Protection
55 | Header unset X-Content-Type-Options
56 |
57 |
58 |
59 | # Browser Caching
60 |
61 |
62 | ExpiresActive on
63 | ExpiresDefault "access plus 1 month"
64 |
65 | # DATA
66 | ExpiresByType text/xml "access plus 0 seconds"
67 | ExpiresByType text/html "access plus 0 seconds"
68 | ExpiresByType text/plain "access plus 0 seconds"
69 | ExpiresByType application/xml "access plus 0 seconds"
70 | ExpiresByType application/json "access plus 0 seconds"
71 | ExpiresByType application/rss+xml "access plus 1 hour"
72 | ExpiresByType application/atom+xml "access plus 1 hour"
73 | ExpiresByType text/x-component "access plus 1 hour"
74 |
75 | # MANIFEST
76 | ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds"
77 | ExpiresByType text/cache-manifest "access plus 0 seconds"
78 |
79 | # SCRIPTS
80 | ExpiresByType text/css "access plus 1 month"
81 | ExpiresByType text/javascript "access plus 1 month"
82 | ExpiresByType application/javascript "access plus 1 month"
83 | ExpiresByType application/x-javascript "access plus 1 month"
84 |
85 | # IMAGES
86 | ExpiresByType image/gif "access plus 1 year"
87 | ExpiresByType image/png "access plus 1 year"
88 | ExpiresByType image/jpe "access plus 1 year"
89 | ExpiresByType image/jpg "access plus 1 year"
90 | ExpiresByType image/jpeg "access plus 1 year"
91 | ExpiresByType image/jp2 "access plus 1 year"
92 | ExpiresByType image/pipeg "access plus 1 year"
93 | ExpiresByType image/bmp "access plus 1 year"
94 | ExpiresByType image/tiff "access plus 1 year"
95 | ExpiresByType image/svg+xml "access plus 1 year"
96 | ExpiresByType image/vnd.microsoft.icon "access plus 1 year"
97 |
98 | # ICONS
99 | ExpiresByType image/ico "access plus 1 year"
100 | ExpiresByType image/icon "access plus 1 year"
101 | ExpiresByType text/ico "access plus 1 year"
102 | ExpiresByType image/x-ico "access plus 1 year"
103 | ExpiresByType image/x-icon "access plus 1 year"
104 | ExpiresByType application/ico "access plus 1 year"
105 |
106 | # AUDIO
107 | ExpiresByType audio/ogg "access plus 1 year"
108 | ExpiresByType audio/basic "access plus 1 year"
109 | ExpiresByType audio/mid "access plus 1 year"
110 | ExpiresByType audio/midi "access plus 1 year"
111 | ExpiresByType audio/mpeg "access plus 1 year"
112 | ExpiresByType audio/x-aiff "access plus 1 year"
113 | ExpiresByType audio/x-mpegurl "access plus 1 year"
114 | ExpiresByType audio/x-pn-realaudio "access plus 1 year"
115 | ExpiresByType audio/x-wav "access plus 1 year"
116 |
117 | # VIDEO
118 | ExpiresByType video/ogg "access plus 1 year"
119 | ExpiresByType video/mp4 "access plus 1 year"
120 | ExpiresByType video/webm "access plus 1 year"
121 | ExpiresByType video/x-msvideo "access plus 1 year"
122 | ExpiresByType video/mpeg "access plus 1 year"
123 | ExpiresByType video/quicktime "access plus 1 year"
124 | ExpiresByType video/x-la-asf "access plus 1 year"
125 | ExpiresByType video/x-ms-asf "access plus 1 year"
126 | ExpiresByType x-world/x-vrml "access plus 1 year"
127 |
128 | # FONTS
129 | ExpiresByType font/truetype "access plus 1 year"
130 | ExpiresByType font/opentype "access plus 1 year"
131 | ExpiresByType application/x-font-ttf "access plus 1 year"
132 | ExpiresByType application/x-font-woff "access plus 1 year"
133 | ExpiresByType application/font-woff "access plus 1 year"
134 | ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
135 |
136 | # FLASH
137 | ExpiresByType application/x-shockwave-flash "access plus 1 year"
138 | ExpiresByType video/x-flv "access plus 1 year"
139 |
140 | # OTHERS
141 | ExpiresByType application/pdf "access plus 1 year"
142 | ExpiresByType image/vnd.wap.wbmp "access plus 1 year"
143 | ExpiresByType application/vnd.wap.wbxml "access plus 1 year"
144 | ExpiresByType application/smil "access plus 1 year"
145 |
146 |
147 | Header append Cache-Control "public"
148 |
149 |
150 |
151 |
--------------------------------------------------------------------------------
/exampleSite/content/post/goisforlovers.md:
--------------------------------------------------------------------------------
1 | +++
2 | title = "(Hu)go Template Primer"
3 | description = ""
4 | tags = [
5 | "go",
6 | "golang",
7 | "templates",
8 | "themes",
9 | "development",
10 | ]
11 | date = "2014-04-02"
12 | categories = [
13 | "Development",
14 | "golang",
15 | ]
16 | menu = "main"
17 | +++
18 |
19 | Hugo uses the excellent [Go][] [html/template][gohtmltemplate] library for
20 | its template engine. It is an extremely lightweight engine that provides a very
21 | small amount of logic. In our experience that it is just the right amount of
22 | logic to be able to create a good static website. If you have used other
23 | template systems from different languages or frameworks you will find a lot of
24 | similarities in Go templates.
25 |
26 | This document is a brief primer on using Go templates. The [Go docs][gohtmltemplate]
27 | provide more details.
28 |
29 | ## Introduction to Go Templates
30 |
31 | Go templates provide an extremely simple template language. It adheres to the
32 | belief that only the most basic of logic belongs in the template or view layer.
33 | One consequence of this simplicity is that Go templates parse very quickly.
34 |
35 | A unique characteristic of Go templates is they are content aware. Variables and
36 | content will be sanitized depending on the context of where they are used. More
37 | details can be found in the [Go docs][gohtmltemplate].
38 |
39 | ## Basic Syntax
40 |
41 | Golang templates are HTML files with the addition of variables and
42 | functions.
43 |
44 | **Go variables and functions are accessible within {{ }}**
45 |
46 | Accessing a predefined variable "foo":
47 |
48 | {{ foo }}
49 |
50 | **Parameters are separated using spaces**
51 |
52 | Calling the add function with input of 1, 2:
53 |
54 | {{ add 1 2 }}
55 |
56 | **Methods and fields are accessed via dot notation**
57 |
58 | Accessing the Page Parameter "bar"
59 |
60 | {{ .Params.bar }}
61 |
62 | **Parentheses can be used to group items together**
63 |
64 | {{ if or (isset .Params "alt") (isset .Params "caption") }} Caption {{ end }}
65 |
66 |
67 | ## Variables
68 |
69 | Each Go template has a struct (object) made available to it. In hugo each
70 | template is passed either a page or a node struct depending on which type of
71 | page you are rendering. More details are available on the
72 | [variables](/layout/variables) page.
73 |
74 | A variable is accessed by referencing the variable name.
75 |
76 | {{ .Title }}
77 |
78 | Variables can also be defined and referenced.
79 |
80 | {{ $address := "123 Main St."}}
81 | {{ $address }}
82 |
83 |
84 | ## Functions
85 |
86 | Go template ship with a few functions which provide basic functionality. The Go
87 | template system also provides a mechanism for applications to extend the
88 | available functions with their own. [Hugo template
89 | functions](/layout/functions) provide some additional functionality we believe
90 | are useful for building websites. Functions are called by using their name
91 | followed by the required parameters separated by spaces. Template
92 | functions cannot be added without recompiling hugo.
93 |
94 | **Example:**
95 |
96 | {{ add 1 2 }}
97 |
98 | ## Includes
99 |
100 | When including another template you will pass to it the data it will be
101 | able to access. To pass along the current context please remember to
102 | include a trailing dot. The templates location will always be starting at
103 | the /layout/ directory within Hugo.
104 |
105 | **Example:**
106 |
107 | {{ template "chrome/header.html" . }}
108 |
109 |
110 | ## Logic
111 |
112 | Go templates provide the most basic iteration and conditional logic.
113 |
114 | ### Iteration
115 |
116 | Just like in Go, the Go templates make heavy use of range to iterate over
117 | a map, array or slice. The following are different examples of how to use
118 | range.
119 |
120 | **Example 1: Using Context**
121 |
122 | {{ range array }}
123 | {{ . }}
124 | {{ end }}
125 |
126 | **Example 2: Declaring value variable name**
127 |
128 | {{range $element := array}}
129 | {{ $element }}
130 | {{ end }}
131 |
132 | **Example 2: Declaring key and value variable name**
133 |
134 | {{range $index, $element := array}}
135 | {{ $index }}
136 | {{ $element }}
137 | {{ end }}
138 |
139 | ### Conditionals
140 |
141 | If, else, with, or, & and provide the framework for handling conditional
142 | logic in Go Templates. Like range, each statement is closed with `end`.
143 |
144 |
145 | Go Templates treat the following values as false:
146 |
147 | * false
148 | * 0
149 | * any array, slice, map, or string of length zero
150 |
151 | **Example 1: If**
152 |
153 | {{ if isset .Params "title" }}
{{ index .Params "title" }}
{{ end }}
154 |
155 | **Example 2: If -> Else**
156 |
157 | {{ if isset .Params "alt" }}
158 | {{ index .Params "alt" }}
159 | {{else}}
160 | {{ index .Params "caption" }}
161 | {{ end }}
162 |
163 | **Example 3: And & Or**
164 |
165 | {{ if and (or (isset .Params "title") (isset .Params "caption")) (isset .Params "attr")}}
166 |
167 | **Example 4: With**
168 |
169 | An alternative way of writing "if" and then referencing the same value
170 | is to use "with" instead. With rebinds the context `.` within its scope,
171 | and skips the block if the variable is absent.
172 |
173 | The first example above could be simplified as:
174 |
175 | {{ with .Params.title }}
{{ . }}
{{ end }}
176 |
177 | **Example 5: If -> Else If**
178 |
179 | {{ if isset .Params "alt" }}
180 | {{ index .Params "alt" }}
181 | {{ else if isset .Params "caption" }}
182 | {{ index .Params "caption" }}
183 | {{ end }}
184 |
185 | ## Pipes
186 |
187 | One of the most powerful components of Go templates is the ability to
188 | stack actions one after another. This is done by using pipes. Borrowed
189 | from unix pipes, the concept is simple, each pipeline's output becomes the
190 | input of the following pipe.
191 |
192 | Because of the very simple syntax of Go templates, the pipe is essential
193 | to being able to chain together function calls. One limitation of the
194 | pipes is that they only can work with a single value and that value
195 | becomes the last parameter of the next pipeline.
196 |
197 | A few simple examples should help convey how to use the pipe.
198 |
199 | **Example 1 :**
200 |
201 | {{ if eq 1 1 }} Same {{ end }}
202 |
203 | is the same as
204 |
205 | {{ eq 1 1 | if }} Same {{ end }}
206 |
207 | It does look odd to place the if at the end, but it does provide a good
208 | illustration of how to use the pipes.
209 |
210 | **Example 2 :**
211 |
212 | {{ index .Params "disqus_url" | html }}
213 |
214 | Access the page parameter called "disqus_url" and escape the HTML.
215 |
216 | **Example 3 :**
217 |
218 | {{ if or (or (isset .Params "title") (isset .Params "caption")) (isset .Params "attr")}}
219 | Stuff Here
220 | {{ end }}
221 |
222 | Could be rewritten as
223 |
224 | {{ isset .Params "caption" | or isset .Params "title" | or isset .Params "attr" | if }}
225 | Stuff Here
226 | {{ end }}
227 |
228 |
229 | ## Context (aka. the dot)
230 |
231 | The most easily overlooked concept to understand about Go templates is that {{ . }}
232 | always refers to the current context. In the top level of your template this
233 | will be the data set made available to it. Inside of a iteration it will have
234 | the value of the current item. When inside of a loop the context has changed. .
235 | will no longer refer to the data available to the entire page. If you need to
236 | access this from within the loop you will likely want to set it to a variable
237 | instead of depending on the context.
238 |
239 | **Example:**
240 |
241 | {{ $title := .Site.Title }}
242 | {{ range .Params.tags }}
243 |
244 | {{ end }}
245 |
246 | Notice how once we have entered the loop the value of {{ . }} has changed. We
247 | have defined a variable outside of the loop so we have access to it from within
248 | the loop.
249 |
250 | # Hugo Parameters
251 |
252 | Hugo provides the option of passing values to the template language
253 | through the site configuration (for sitewide values), or through the meta
254 | data of each specific piece of content. You can define any values of any
255 | type (supported by your front matter/config format) and use them however
256 | you want to inside of your templates.
257 |
258 |
259 | ## Using Content (page) Parameters
260 |
261 | In each piece of content you can provide variables to be used by the
262 | templates. This happens in the [front matter](/content/front-matter).
263 |
264 | An example of this is used in this documentation site. Most of the pages
265 | benefit from having the table of contents provided. Sometimes the TOC just
266 | doesn't make a lot of sense. We've defined a variable in our front matter
267 | of some pages to turn off the TOC from being displayed.
268 |
269 | Here is the example front matter:
270 |
271 | ```
272 | ---
273 | title: "Permalinks"
274 | date: "2013-11-18"
275 | aliases:
276 | - "/doc/permalinks/"
277 | groups: ["extras"]
278 | groups_weight: 30
279 | notoc: true
280 | ---
281 | ```
282 |
283 | Here is the corresponding code inside of the template:
284 |
285 | {{ if not .Params.notoc }}
286 |