forked from mirror/Mainroad
Initial version
This commit is contained in:
commit
31e4c6c9a2
36 changed files with 4895 additions and 0 deletions
LICENSE.mdREADME.md
archetypes
exampleSite
images
layouts
_default
partials
static
theme.toml
361
LICENSE.md
Normal file
361
LICENSE.md
Normal file
|
@ -0,0 +1,361 @@
|
|||
### GNU GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
### Preamble
|
||||
|
||||
The licenses for most software are designed to take away your freedom
|
||||
to share and change it. By contrast, the GNU General Public License is
|
||||
intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if
|
||||
you distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on,
|
||||
we want its recipients to know that what they have is not the
|
||||
original, so that any problems introduced by others will not reflect
|
||||
on the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at
|
||||
all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
### TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
**0.** This License applies to any program or other work which
|
||||
contains a notice placed by the copyright holder saying it may be
|
||||
distributed under the terms of this General Public License. The
|
||||
"Program", below, refers to any such program or work, and a "work
|
||||
based on the Program" means either the Program or any derivative work
|
||||
under copyright law: that is to say, a work containing the Program or
|
||||
a portion of it, either verbatim or with modifications and/or
|
||||
translated into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".) Each licensee
|
||||
is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the Program
|
||||
(independent of having been made by running the Program). Whether that
|
||||
is true depends on what the Program does.
|
||||
|
||||
**1.** You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
**2.** You may modify your copy or copies of the Program or any
|
||||
portion of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
|
||||
**a)** You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
|
||||
**b)** You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any part
|
||||
thereof, to be licensed as a whole at no charge to all third parties
|
||||
under the terms of this License.
|
||||
|
||||
|
||||
**c)** If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such interactive
|
||||
use in the most ordinary way, to print or display an announcement
|
||||
including an appropriate copyright notice and a notice that there is
|
||||
no warranty (or else, saying that you provide a warranty) and that
|
||||
users may redistribute the program under these conditions, and telling
|
||||
the user how to view a copy of this License. (Exception: if the
|
||||
Program itself is interactive but does not normally print such an
|
||||
announcement, your work based on the Program is not required to print
|
||||
an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
**3.** You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
|
||||
**a)** Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections 1
|
||||
and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
|
||||
**b)** Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your cost of
|
||||
physically performing source distribution, a complete machine-readable
|
||||
copy of the corresponding source code, to be distributed under the
|
||||
terms of Sections 1 and 2 above on a medium customarily used for
|
||||
software interchange; or,
|
||||
|
||||
|
||||
**c)** Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is allowed
|
||||
only for noncommercial distribution and only if you received the
|
||||
program in object code or executable form with such an offer, in
|
||||
accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
**4.** You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt otherwise
|
||||
to copy, modify, sublicense or distribute the Program is void, and
|
||||
will automatically terminate your rights under this License. However,
|
||||
parties who have received copies, or rights, from you under this
|
||||
License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
**5.** You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
**6.** Each time you redistribute the Program (or any work based on
|
||||
the Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
**7.** If, as a consequence of a court judgment or allegation of
|
||||
patent infringement or for any other reason (not limited to patent
|
||||
issues), conditions are imposed on you (whether by court order,
|
||||
agreement or otherwise) that contradict the conditions of this
|
||||
License, they do not excuse you from the conditions of this License.
|
||||
If you cannot distribute so as to satisfy simultaneously your
|
||||
obligations under this License and any other pertinent obligations,
|
||||
then as a consequence you may not distribute the Program at all. For
|
||||
example, if a patent license would not permit royalty-free
|
||||
redistribution of the Program by all those who receive copies directly
|
||||
or indirectly through you, then the only way you could satisfy both it
|
||||
and this License would be to refrain entirely from distribution of the
|
||||
Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
**8.** If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
**9.** The Free Software Foundation may publish revised and/or new
|
||||
versions of the General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Program does not specify a
|
||||
version number of this License, you may choose any version ever
|
||||
published by the Free Software Foundation.
|
||||
|
||||
**10.** If you wish to incorporate parts of the Program into other
|
||||
free programs whose distribution conditions are different, write to
|
||||
the author to ask for permission. For software which is copyrighted by
|
||||
the Free Software Foundation, write to the Free Software Foundation;
|
||||
we sometimes make exceptions for this. Our decision will be guided by
|
||||
the two goals of preserving the free status of all derivatives of our
|
||||
free software and of promoting the sharing and reuse of software
|
||||
generally.
|
||||
|
||||
**NO WARRANTY**
|
||||
|
||||
**11.** BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
**12.** IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
### END OF TERMS AND CONDITIONS
|
||||
|
||||
### How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these
|
||||
terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to
|
||||
attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
one line to give the program's name and an idea of what it does.
|
||||
Copyright (C) yyyy name of author
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper
|
||||
mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
|
||||
type `show w'. This is free software, and you are welcome
|
||||
to redistribute it under certain conditions; type `show c'
|
||||
for details.
|
||||
|
||||
The hypothetical commands \`show w' and \`show c' should show the
|
||||
appropriate parts of the General Public License. Of course, the
|
||||
commands you use may be called something other than \`show w' and
|
||||
\`show c'; they could even be mouse-clicks or menu items--whatever
|
||||
suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or
|
||||
your school, if any, to sign a "copyright disclaimer" for the program,
|
||||
if necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright
|
||||
interest in the program `Gnomovision'
|
||||
(which makes passes at compilers) written
|
||||
by James Hacker.
|
||||
|
||||
signature of Ty Coon, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library,
|
||||
you may consider it more useful to permit linking proprietary
|
||||
applications with the library. If this is what you want to do, use the
|
||||
[GNU Lesser General Public
|
||||
License](http://www.gnu.org/licenses/lgpl.html) instead of this
|
||||
License.
|
83
README.md
Normal file
83
README.md
Normal file
|
@ -0,0 +1,83 @@
|
|||
# Mainroad
|
||||
|
||||
**Mainroad** is a responsive, simple, clean and content-focused [Hugo](//gohugo.io/) theme based on the [MH Magazine lite](//wordpress.org/themes/mh-magazine-lite/) WordPress theme by [MH Themes](//www.mhthemes.com/).
|
||||
|
||||

|
||||
|
||||
Adaptation has several changes:
|
||||
|
||||
+ Include Hugo internal templates (Open Graph, Disqus, Google Analytics)
|
||||
+ SVG icons instead of font icons
|
||||
+ Theme options are saved (Sidebar position, Author Box, Post Navigation) and available through config.toml file parameters
|
||||
+ Other small changes
|
||||
|
||||
## Installation
|
||||
|
||||
In your Hugo site `themes` directory, run:
|
||||
|
||||
```
|
||||
$ git clone https://github.com/vimux/mainroad
|
||||
```
|
||||
|
||||
Next, open `config.toml` in the base of the Hugo site and ensure the theme option is set to `mainroad`:
|
||||
|
||||
```
|
||||
theme = "mainroad"
|
||||
```
|
||||
|
||||
For more information read the official [setup guide](//gohugo.io/themes/installing/) of Hugo.
|
||||
|
||||
## Configuration
|
||||
|
||||
### Example config.toml
|
||||
|
||||
```toml
|
||||
baseurl = "http://replace-this-with-your-hugo-site.com/"
|
||||
title = "Mainroad"
|
||||
languageCode = "en-us"
|
||||
paginate = "10" # Number of posts per page
|
||||
theme = "mainroad"
|
||||
disqusShortname = "" # Enable comments by entering your Disqus shortname
|
||||
|
||||
|
||||
[Author]
|
||||
name = "John Doe"
|
||||
bio = "John Doe's true identity is unknown. Maybe he is a successful blogger or writer. Nobody knows it."
|
||||
avatar = "img/avatar.png"
|
||||
|
||||
|
||||
[Params]
|
||||
subtitle = "Just another site" # Subtitle of your site
|
||||
description = " John Doe's Personal blog about everything" # Description of your site
|
||||
opengraph = true
|
||||
leftsidebar = false # Move sidebar to the left side if true
|
||||
authorbox = true
|
||||
post_navigation = true
|
||||
|
||||
|
||||
[Params.widgets]
|
||||
search = true # Enable "Search" widget
|
||||
recent_articles = true # Enable "Recent arcticles" widget
|
||||
categories = true # Enable "Categories" widget
|
||||
tags = true # Enable "Tags" widget
|
||||
```
|
||||
|
||||
## TODO
|
||||
|
||||
- [ ] Delete unused CSS
|
||||
- [ ] No ID in CSS
|
||||
- [ ] Responsive menu without JS and jQuery
|
||||
- [ ] Delete unused JS
|
||||
- [ ] i18n support (Internationalization)
|
||||
- [ ] Detailed documentation (?)
|
||||
- [ ] Social media widget (?)
|
||||
- [ ] Enhanced version of recent posts widget (?)
|
||||
- [ ] Tabbed widget (?)
|
||||
|
||||
## Contributing
|
||||
|
||||
Have you found a bug or got an idea for a new feature? Feel free to use the [issue tracker](//github.com/Vimux/mainroad/issues) to let me know. Or make directly a [pull request](//github.com/Vimux/mainroad/pulls).
|
||||
|
||||
## License
|
||||
|
||||
This theme is released under the [GPLv2 license](//github.com/Vimux/mainroad/blob/master/LICENSE.md) (inherited from the original MH Magazine lite WordPress theme).
|
8
archetypes/default.md
Normal file
8
archetypes/default.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
+++
|
||||
title = ""
|
||||
description = ""
|
||||
date = ""
|
||||
categories = []
|
||||
tags = []
|
||||
thumbnail = ""
|
||||
+++
|
2
exampleSite/.gitignore
vendored
Normal file
2
exampleSite/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
public/
|
||||
themes
|
28
exampleSite/config.toml
Normal file
28
exampleSite/config.toml
Normal file
|
@ -0,0 +1,28 @@
|
|||
baseurl = "http://replace-this-with-your-hugo-site.com/"
|
||||
title = "Mainroad"
|
||||
languageCode = "en-us"
|
||||
paginate = "10" # Number of posts per page
|
||||
theme = "mainroad"
|
||||
disqusShortname = "" # Enable comments by entering your Disqus shortname
|
||||
|
||||
|
||||
[Author]
|
||||
name = "John Doe"
|
||||
bio = "John Doe's true identity is unknown. Maybe he is a successful blogger or writer. Nobody knows it."
|
||||
avatar = "img/avatar.png"
|
||||
|
||||
|
||||
[Params]
|
||||
subtitle = "Just another site" # Subtitle of your site
|
||||
description = " John Doe's Personal blog about everything" # Description of your site
|
||||
opengraph = true
|
||||
leftsidebar = false # Move sidebar to the left side if true
|
||||
authorbox = true
|
||||
post_navigation = true
|
||||
|
||||
|
||||
[Params.widgets]
|
||||
search = true # Enable "Search" widget
|
||||
recent_articles = true # Enable "Recent arcticles" widget
|
||||
categories = true # Enable "Categories" widget
|
||||
tags = true # Enable "Tags" widget
|
30
exampleSite/content/about.md
Normal file
30
exampleSite/content/about.md
Normal file
|
@ -0,0 +1,30 @@
|
|||
+++
|
||||
title = "About Hugo"
|
||||
date = "2014-04-09"
|
||||
menu = "main"
|
||||
+++
|
||||
|
||||
Hugo is a static site engine written in Go.
|
||||
|
||||
|
||||
It makes use of a variety of open source projects including:
|
||||
|
||||
* [Cobra](https://github.com/spf13/cobra)
|
||||
* [Viper](https://github.com/spf13/viper)
|
||||
* [J Walter Weatherman](https://github.com/spf13/jWalterWeatherman)
|
||||
* [Cast](https://github.com/spf13/cast)
|
||||
|
||||
Learn more and contribute on [GitHub](https://github.com/spf13).
|
||||
|
||||
## Setup
|
||||
|
||||
Some fun facts about [Hugo](http://gohugo.io/):
|
||||
|
||||
* Built in [Go](http://golang.org/)
|
||||
* Loosely inspired by [Jekyll](http://jekyllrb.com/)
|
||||
* Primarily developed by [spf13](http://spf13.com/) on the train while commuting to and from Manhattan.
|
||||
* Coded in [Vim](http://vim.org) using [spf13-vim](http://vim.spf13.com/)
|
||||
|
||||
Have questions or suggestions? Feel free to [open an issue on GitHub](https://github.com/spf13/hugo/issues/new) or [ask me on Twitter](https://twitter.com/spf13).
|
||||
|
||||
Thanks for reading!
|
1150
exampleSite/content/post/creating-a-new-theme.md
Normal file
1150
exampleSite/content/post/creating-a-new-theme.md
Normal file
File diff suppressed because it is too large
Load diff
347
exampleSite/content/post/goisforlovers.md
Normal file
347
exampleSite/content/post/goisforlovers.md
Normal file
|
@ -0,0 +1,347 @@
|
|||
+++
|
||||
title = "(Hu)go Template Primer"
|
||||
description = ""
|
||||
tags = [
|
||||
"go",
|
||||
"golang",
|
||||
"templates",
|
||||
"themes",
|
||||
"development",
|
||||
]
|
||||
date = "2014-04-02"
|
||||
categories = [
|
||||
"Development",
|
||||
"golang",
|
||||
]
|
||||
menu = "main"
|
||||
thumbnail = "img/placeholder.png"
|
||||
+++
|
||||
|
||||
Hugo uses the excellent [go][] [html/template][gohtmltemplate] library for
|
||||
its template engine. It is an extremely lightweight engine that provides a very
|
||||
small amount of logic. In our experience that it is just the right amount of
|
||||
logic to be able to create a good static website. If you have used other
|
||||
template systems from different languages or frameworks you will find a lot of
|
||||
similarities in go templates.
|
||||
|
||||
<!--more-->
|
||||
|
||||
This document is a brief primer on using go templates. The [go docs][gohtmltemplate]
|
||||
provide more details.
|
||||
|
||||
## Introduction to Go Templates
|
||||
|
||||
Go templates provide an extremely simple template language. It adheres to the
|
||||
belief that only the most basic of logic belongs in the template or view layer.
|
||||
One consequence of this simplicity is that go templates parse very quickly.
|
||||
|
||||
A unique characteristic of go templates is they are content aware. Variables and
|
||||
content will be sanitized depending on the context of where they are used. More
|
||||
details can be found in the [go docs][gohtmltemplate].
|
||||
|
||||
## Basic Syntax
|
||||
|
||||
Go lang templates are html files with the addition of variables and
|
||||
functions.
|
||||
|
||||
**Go variables and functions are accessible within {{ }}**
|
||||
|
||||
Accessing a predefined variable "foo":
|
||||
|
||||
{{ foo }}
|
||||
|
||||
**Parameters are separated using spaces**
|
||||
|
||||
Calling the add function with input of 1, 2:
|
||||
|
||||
{{ add 1 2 }}
|
||||
|
||||
**Methods and fields are accessed via dot notation**
|
||||
|
||||
Accessing the Page Parameter "bar"
|
||||
|
||||
{{ .Params.bar }}
|
||||
|
||||
**Parentheses can be used to group items together**
|
||||
|
||||
{{ if or (isset .Params "alt") (isset .Params "caption") }} Caption {{ end }}
|
||||
|
||||
|
||||
## Variables
|
||||
|
||||
Each go template has a struct (object) made available to it. In hugo each
|
||||
template is passed either a page or a node struct depending on which type of
|
||||
page you are rendering. More details are available on the
|
||||
[variables](/layout/variables) page.
|
||||
|
||||
A variable is accessed by referencing the variable name.
|
||||
|
||||
<title>{{ .Title }}</title>
|
||||
|
||||
Variables can also be defined and referenced.
|
||||
|
||||
{{ $address := "123 Main St."}}
|
||||
{{ $address }}
|
||||
|
||||
|
||||
## Functions
|
||||
|
||||
Go template ship with a few functions which provide basic functionality. The go
|
||||
template system also provides a mechanism for applications to extend the
|
||||
available functions with their own. [Hugo template
|
||||
functions](/layout/functions) provide some additional functionality we believe
|
||||
are useful for building websites. Functions are called by using their name
|
||||
followed by the required parameters separated by spaces. Template
|
||||
functions cannot be added without recompiling hugo.
|
||||
|
||||
**Example:**
|
||||
|
||||
{{ add 1 2 }}
|
||||
|
||||
## Includes
|
||||
|
||||
When including another template you will pass to it the data it will be
|
||||
able to access. To pass along the current context please remember to
|
||||
include a trailing dot. The templates location will always be starting at
|
||||
the /layout/ directory within Hugo.
|
||||
|
||||
**Example:**
|
||||
|
||||
{{ template "chrome/header.html" . }}
|
||||
|
||||
|
||||
## Logic
|
||||
|
||||
Go templates provide the most basic iteration and conditional logic.
|
||||
|
||||
### Iteration
|
||||
|
||||
Just like in go, the go templates make heavy use of range to iterate over
|
||||
a map, array or slice. The following are different examples of how to use
|
||||
range.
|
||||
|
||||
**Example 1: Using Context**
|
||||
|
||||
{{ range array }}
|
||||
{{ . }}
|
||||
{{ end }}
|
||||
|
||||
**Example 2: Declaring value variable name**
|
||||
|
||||
{{range $element := array}}
|
||||
{{ $element }}
|
||||
{{ end }}
|
||||
|
||||
**Example 2: Declaring key and value variable name**
|
||||
|
||||
{{range $index, $element := array}}
|
||||
{{ $index }}
|
||||
{{ $element }}
|
||||
{{ end }}
|
||||
|
||||
### Conditionals
|
||||
|
||||
If, else, with, or, & and provide the framework for handling conditional
|
||||
logic in Go Templates. Like range, each statement is closed with `end`.
|
||||
|
||||
|
||||
Go Templates treat the following values as false:
|
||||
|
||||
* false
|
||||
* 0
|
||||
* any array, slice, map, or string of length zero
|
||||
|
||||
**Example 1: If**
|
||||
|
||||
{{ if isset .Params "title" }}<h4>{{ index .Params "title" }}</h4>{{ end }}
|
||||
|
||||
**Example 2: If -> Else**
|
||||
|
||||
{{ if isset .Params "alt" }}
|
||||
{{ index .Params "alt" }}
|
||||
{{else}}
|
||||
{{ index .Params "caption" }}
|
||||
{{ end }}
|
||||
|
||||
**Example 3: And & Or**
|
||||
|
||||
{{ if and (or (isset .Params "title") (isset .Params "caption")) (isset .Params "attr")}}
|
||||
|
||||
**Example 4: With**
|
||||
|
||||
An alternative way of writing "if" and then referencing the same value
|
||||
is to use "with" instead. With rebinds the context `.` within its scope,
|
||||
and skips the block if the variable is absent.
|
||||
|
||||
The first example above could be simplified as:
|
||||
|
||||
{{ with .Params.title }}<h4>{{ . }}</h4>{{ end }}
|
||||
|
||||
**Example 5: If -> Else If**
|
||||
|
||||
{{ if isset .Params "alt" }}
|
||||
{{ index .Params "alt" }}
|
||||
{{ else if isset .Params "caption" }}
|
||||
{{ index .Params "caption" }}
|
||||
{{ end }}
|
||||
|
||||
## Pipes
|
||||
|
||||
One of the most powerful components of go templates is the ability to
|
||||
stack actions one after another. This is done by using pipes. Borrowed
|
||||
from unix pipes, the concept is simple, each pipeline's output becomes the
|
||||
input of the following pipe.
|
||||
|
||||
Because of the very simple syntax of go templates, the pipe is essential
|
||||
to being able to chain together function calls. One limitation of the
|
||||
pipes is that they only can work with a single value and that value
|
||||
becomes the last parameter of the next pipeline.
|
||||
|
||||
A few simple examples should help convey how to use the pipe.
|
||||
|
||||
**Example 1 :**
|
||||
|
||||
{{ if eq 1 1 }} Same {{ end }}
|
||||
|
||||
is the same as
|
||||
|
||||
{{ eq 1 1 | if }} Same {{ end }}
|
||||
|
||||
It does look odd to place the if at the end, but it does provide a good
|
||||
illustration of how to use the pipes.
|
||||
|
||||
**Example 2 :**
|
||||
|
||||
{{ index .Params "disqus_url" | html }}
|
||||
|
||||
Access the page parameter called "disqus_url" and escape the HTML.
|
||||
|
||||
**Example 3 :**
|
||||
|
||||
{{ if or (or (isset .Params "title") (isset .Params "caption")) (isset .Params "attr")}}
|
||||
Stuff Here
|
||||
{{ end }}
|
||||
|
||||
Could be rewritten as
|
||||
|
||||
{{ isset .Params "caption" | or isset .Params "title" | or isset .Params "attr" | if }}
|
||||
Stuff Here
|
||||
{{ end }}
|
||||
|
||||
|
||||
## Context (aka. the dot)
|
||||
|
||||
The most easily overlooked concept to understand about go templates is that {{ . }}
|
||||
always refers to the current context. In the top level of your template this
|
||||
will be the data set made available to it. Inside of a iteration it will have
|
||||
the value of the current item. When inside of a loop the context has changed. .
|
||||
will no longer refer to the data available to the entire page. If you need to
|
||||
access this from within the loop you will likely want to set it to a variable
|
||||
instead of depending on the context.
|
||||
|
||||
**Example:**
|
||||
|
||||
{{ $title := .Site.Title }}
|
||||
{{ range .Params.tags }}
|
||||
<li> <a href="{{ $baseurl }}/tags/{{ . | urlize }}">{{ . }}</a> - {{ $title }} </li>
|
||||
{{ end }}
|
||||
|
||||
Notice how once we have entered the loop the value of {{ . }} has changed. We
|
||||
have defined a variable outside of the loop so we have access to it from within
|
||||
the loop.
|
||||
|
||||
# Hugo Parameters
|
||||
|
||||
Hugo provides the option of passing values to the template language
|
||||
through the site configuration (for sitewide values), or through the meta
|
||||
data of each specific piece of content. You can define any values of any
|
||||
type (supported by your front matter/config format) and use them however
|
||||
you want to inside of your templates.
|
||||
|
||||
|
||||
## Using Content (page) Parameters
|
||||
|
||||
In each piece of content you can provide variables to be used by the
|
||||
templates. This happens in the [front matter](/content/front-matter).
|
||||
|
||||
An example of this is used in this documentation site. Most of the pages
|
||||
benefit from having the table of contents provided. Sometimes the TOC just
|
||||
doesn't make a lot of sense. We've defined a variable in our front matter
|
||||
of some pages to turn off the TOC from being displayed.
|
||||
|
||||
Here is the example front matter:
|
||||
|
||||
```
|
||||
---
|
||||
title: "Permalinks"
|
||||
date: "2013-11-18"
|
||||
aliases:
|
||||
- "/doc/permalinks/"
|
||||
groups: ["extras"]
|
||||
groups_weight: 30
|
||||
notoc: true
|
||||
---
|
||||
```
|
||||
|
||||
Here is the corresponding code inside of the template:
|
||||
|
||||
{{ if not .Params.notoc }}
|
||||
<div id="toc" class="well col-md-4 col-sm-6">
|
||||
{{ .TableOfContents }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
|
||||
|
||||
## Using Site (config) Parameters
|
||||
In your top-level configuration file (eg, `config.yaml`) you can define site
|
||||
parameters, which are values which will be available to you in chrome.
|
||||
|
||||
For instance, you might declare:
|
||||
|
||||
```yaml
|
||||
params:
|
||||
CopyrightHTML: "Copyright © 2013 John Doe. All Rights Reserved."
|
||||
TwitterUser: "spf13"
|
||||
SidebarRecentLimit: 5
|
||||
```
|
||||
|
||||
Within a footer layout, you might then declare a `<footer>` which is only
|
||||
provided if the `CopyrightHTML` parameter is provided, and if it is given,
|
||||
you would declare it to be HTML-safe, so that the HTML entity is not escaped
|
||||
again. This would let you easily update just your top-level config file each
|
||||
January 1st, instead of hunting through your templates.
|
||||
|
||||
```
|
||||
{{if .Site.Params.CopyrightHTML}}<footer>
|
||||
<div class="text-center">{{.Site.Params.CopyrightHTML | safeHtml}}</div>
|
||||
</footer>{{end}}
|
||||
```
|
||||
|
||||
An alternative way of writing the "if" and then referencing the same value
|
||||
is to use "with" instead. With rebinds the context `.` within its scope,
|
||||
and skips the block if the variable is absent:
|
||||
|
||||
```
|
||||
{{with .Site.Params.TwitterUser}}<span class="twitter">
|
||||
<a href="https://twitter.com/{{.}}" rel="author">
|
||||
<img src="/images/twitter.png" width="48" height="48" title="Twitter: {{.}}"
|
||||
alt="Twitter"></a>
|
||||
</span>{{end}}
|
||||
```
|
||||
|
||||
Finally, if you want to pull "magic constants" out of your layouts, you can do
|
||||
so, such as in this example:
|
||||
|
||||
```
|
||||
<nav class="recent">
|
||||
<h1>Recent Posts</h1>
|
||||
<ul>{{range first .Site.Params.SidebarRecentLimit .Site.Recent}}
|
||||
<li><a href="{{.RelPermalink}}">{{.Title}}</a></li>
|
||||
{{end}}</ul>
|
||||
</nav>
|
||||
```
|
||||
|
||||
|
||||
[go]: <http://golang.org/>
|
||||
[gohtmltemplate]: <http://golang.org/pkg/html/template/>
|
89
exampleSite/content/post/hugoisforlovers.md
Normal file
89
exampleSite/content/post/hugoisforlovers.md
Normal file
|
@ -0,0 +1,89 @@
|
|||
+++
|
||||
title = "Getting Started with Hugo"
|
||||
description = ""
|
||||
tags = [
|
||||
"go",
|
||||
"golang",
|
||||
"hugo",
|
||||
"development",
|
||||
]
|
||||
date = "2014-04-02"
|
||||
categories = [
|
||||
"Development",
|
||||
"golang",
|
||||
]
|
||||
menu = "main"
|
||||
+++
|
||||
|
||||
## Step 1. Install Hugo
|
||||
|
||||
Goto [hugo releases](https://github.com/spf13/hugo/releases) and download the
|
||||
appropriate version for your os and architecture.
|
||||
|
||||
Save it somewhere specific as we will be using it in the next step.
|
||||
|
||||
More complete instructions are available at [installing hugo](/overview/installing/)
|
||||
|
||||
## Step 2. Build the Docs
|
||||
|
||||
Hugo has its own example site which happens to also be the documentation site
|
||||
you are reading right now.
|
||||
|
||||
Follow the following steps:
|
||||
|
||||
1. Clone the [hugo repository](http://github.com/spf13/hugo)
|
||||
2. Go into the repo
|
||||
3. Run hugo in server mode and build the docs
|
||||
4. Open your browser to http://localhost:1313
|
||||
|
||||
Corresponding pseudo commands:
|
||||
|
||||
git clone https://github.com/spf13/hugo
|
||||
cd hugo
|
||||
/path/to/where/you/installed/hugo server --source=./docs
|
||||
> 29 pages created
|
||||
> 0 tags index created
|
||||
> in 27 ms
|
||||
> Web Server is available at http://localhost:1313
|
||||
> Press ctrl+c to stop
|
||||
|
||||
Once you've gotten here, follow along the rest of this page on your local build.
|
||||
|
||||
## Step 3. Change the docs site
|
||||
|
||||
Stop the Hugo process by hitting ctrl+c.
|
||||
|
||||
Now we are going to run hugo again, but this time with hugo in watch mode.
|
||||
|
||||
/path/to/hugo/from/step/1/hugo server --source=./docs --watch
|
||||
> 29 pages created
|
||||
> 0 tags index created
|
||||
> in 27 ms
|
||||
> Web Server is available at http://localhost:1313
|
||||
> Watching for changes in /Users/spf13/Code/hugo/docs/content
|
||||
> Press ctrl+c to stop
|
||||
|
||||
|
||||
Open your [favorite editor](http://vim.spf13.com) and change one of the source
|
||||
content pages. How about changing this very file to *fix the typo*. How about changing this very file to *fix the typo*.
|
||||
|
||||
Content files are found in `docs/content/`. Unless otherwise specified, files
|
||||
are located at the same relative location as the url, in our case
|
||||
`docs/content/overview/quickstart.md`.
|
||||
|
||||
Change and save this file.. Notice what happened in your terminal.
|
||||
|
||||
> Change detected, rebuilding site
|
||||
|
||||
> 29 pages created
|
||||
> 0 tags index created
|
||||
> in 26 ms
|
||||
|
||||
Refresh the browser and observe that the typo is now fixed.
|
||||
|
||||
Notice how quick that was. Try to refresh the site before it's finished building.. I double dare you.
|
||||
Having nearly instant feedback enables you to have your creativity flow without waiting for long builds.
|
||||
|
||||
## Step 4. Have fun
|
||||
|
||||
The best way to learn something is to play with it.
|
156
exampleSite/content/post/migrate-from-jekyll.md
Normal file
156
exampleSite/content/post/migrate-from-jekyll.md
Normal file
|
@ -0,0 +1,156 @@
|
|||
---
|
||||
date: 2014-03-10
|
||||
linktitle: Migrating from Jekyll
|
||||
menu:
|
||||
main:
|
||||
parent: tutorials
|
||||
prev: /tutorials/mathjax
|
||||
title: Migrate to Hugo from Jekyll
|
||||
weight: 10
|
||||
---
|
||||
|
||||
## Move static content to `static`
|
||||
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.
|
||||
With Jekyll, something that looked like
|
||||
|
||||
▾ <root>/
|
||||
▾ images/
|
||||
logo.png
|
||||
|
||||
should become
|
||||
|
||||
▾ <root>/
|
||||
▾ static/
|
||||
▾ images/
|
||||
logo.png
|
||||
|
||||
Additionally, you'll want any files that should reside at the root (such as `CNAME`) to be moved to `static`.
|
||||
|
||||
## Create your Hugo configuration file
|
||||
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.
|
||||
|
||||
## Set your configuration publish folder to `_site`
|
||||
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:
|
||||
|
||||
1. Change your submodule to point to map `gh-pages` to public instead of `_site` (recommended).
|
||||
|
||||
git submodule deinit _site
|
||||
git rm _site
|
||||
git submodule add -b gh-pages git@github.com:your-username/your-repo.git public
|
||||
|
||||
2. Or, change the Hugo configuration to use `_site` instead of `public`.
|
||||
|
||||
{
|
||||
..
|
||||
"publishdir": "_site",
|
||||
..
|
||||
}
|
||||
|
||||
## Convert Jekyll templates to Hugo templates
|
||||
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.
|
||||
|
||||
As a single reference data point, converting my templates for [heyitsalex.net](http://heyitsalex.net/) took me no more than a few hours.
|
||||
|
||||
## Convert Jekyll plugins to Hugo shortcodes
|
||||
Jekyll has [plugins](http://jekyllrb.com/docs/plugins/); Hugo has [shortcodes](/doc/shortcodes/). It's fairly trivial to do a port.
|
||||
|
||||
### Implementation
|
||||
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.
|
||||
|
||||
Jekyll's plugin:
|
||||
|
||||
module Jekyll
|
||||
class ImageTag < Liquid::Tag
|
||||
@url = nil
|
||||
@caption = nil
|
||||
@class = nil
|
||||
@link = nil
|
||||
// Patterns
|
||||
IMAGE_URL_WITH_CLASS_AND_CAPTION =
|
||||
IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK = /(\w+)(\s+)((https?:\/\/|\/)(\S+))(\s+)"(.*?)"(\s+)->((https?:\/\/|\/)(\S+))(\s*)/i
|
||||
IMAGE_URL_WITH_CAPTION = /((https?:\/\/|\/)(\S+))(\s+)"(.*?)"/i
|
||||
IMAGE_URL_WITH_CLASS = /(\w+)(\s+)((https?:\/\/|\/)(\S+))/i
|
||||
IMAGE_URL = /((https?:\/\/|\/)(\S+))/i
|
||||
def initialize(tag_name, markup, tokens)
|
||||
super
|
||||
if markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK
|
||||
@class = $1
|
||||
@url = $3
|
||||
@caption = $7
|
||||
@link = $9
|
||||
elsif markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION
|
||||
@class = $1
|
||||
@url = $3
|
||||
@caption = $7
|
||||
elsif markup =~ IMAGE_URL_WITH_CAPTION
|
||||
@url = $1
|
||||
@caption = $5
|
||||
elsif markup =~ IMAGE_URL_WITH_CLASS
|
||||
@class = $1
|
||||
@url = $3
|
||||
elsif markup =~ IMAGE_URL
|
||||
@url = $1
|
||||
end
|
||||
end
|
||||
def render(context)
|
||||
if @class
|
||||
source = "<figure class='#{@class}'>"
|
||||
else
|
||||
source = "<figure>"
|
||||
end
|
||||
if @link
|
||||
source += "<a href=\"#{@link}\">"
|
||||
end
|
||||
source += "<img src=\"#{@url}\">"
|
||||
if @link
|
||||
source += "</a>"
|
||||
end
|
||||
source += "<figcaption>#{@caption}</figcaption>" if @caption
|
||||
source += "</figure>"
|
||||
source
|
||||
end
|
||||
end
|
||||
end
|
||||
Liquid::Template.register_tag('image', Jekyll::ImageTag)
|
||||
|
||||
is written as this Hugo shortcode:
|
||||
|
||||
<!-- image -->
|
||||
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}>
|
||||
{{ with .Get "link"}}<a href="{{.}}">{{ end }}
|
||||
<img src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}"{{ end }} />
|
||||
{{ if .Get "link"}}</a>{{ end }}
|
||||
{{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
|
||||
<figcaption>{{ if isset .Params "title" }}
|
||||
{{ .Get "title" }}{{ end }}
|
||||
{{ if or (.Get "caption") (.Get "attr")}}<p>
|
||||
{{ .Get "caption" }}
|
||||
{{ with .Get "attrlink"}}<a href="{{.}}"> {{ end }}
|
||||
{{ .Get "attr" }}
|
||||
{{ if .Get "attrlink"}}</a> {{ end }}
|
||||
</p> {{ end }}
|
||||
</figcaption>
|
||||
{{ end }}
|
||||
</figure>
|
||||
<!-- image -->
|
||||
|
||||
### Usage
|
||||
I simply changed:
|
||||
|
||||
{% 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/ %}
|
||||
|
||||
to this (this example uses a slightly extended version named `fig`, different than the built-in `figure`):
|
||||
|
||||
{{%/* 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/" */%}}
|
||||
|
||||
As a bonus, the shortcode named parameters are, arguably, more readable.
|
||||
|
||||
## Finishing touches
|
||||
### Fix content
|
||||
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.
|
||||
|
||||
### Clean up
|
||||
You'll want to remove the Jekyll configuration at this point. If you have anything else that isn't used, delete it.
|
||||
|
||||
## A practical example in a diff
|
||||
[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).
|
0
exampleSite/data/.gitkeep
Normal file
0
exampleSite/data/.gitkeep
Normal file
0
exampleSite/static/.gitkeep
Normal file
0
exampleSite/static/.gitkeep
Normal file
BIN
images/screenshot.png
Normal file
BIN
images/screenshot.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 81 KiB |
BIN
images/tn.png
Normal file
BIN
images/tn.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 137 KiB |
42
layouts/_default/list.html
Normal file
42
layouts/_default/list.html
Normal file
|
@ -0,0 +1,42 @@
|
|||
{{ partial "header.html" . }}
|
||||
|
||||
<div id="main-content" class="mr-loop mr-content" role="main">
|
||||
{{ if not .IsHome }}
|
||||
<header class="page-header">
|
||||
<h1 class="page-title">{{ .Title }}</h1>
|
||||
</header>
|
||||
{{ end }}
|
||||
{{ $paginator := .Paginate .Data.Pages }}
|
||||
{{ range $paginator.Pages }}
|
||||
<article class="mr-loop-item post type-post hentry clearfix">
|
||||
{{ if .Params.thumbnail }}
|
||||
<figure class="mr-loop-thumb">
|
||||
<a href="{{ .Permalink }}">
|
||||
<img class="mr-image-placeholder" src="{{ .Params.thumbnail | absURL }}" alt="{{ .Title }}" />
|
||||
</a>
|
||||
</figure>
|
||||
{{ end }}
|
||||
<div class="mr-loop-content clearfix">
|
||||
<header class="mr-loop-header">
|
||||
<h3 class="entry-title mr-loop-title">
|
||||
<a href="{{ .Permalink }}" rel="bookmark">{{ .Title }}</a>
|
||||
</h3>
|
||||
<div class="mr-meta mr-loop-meta">
|
||||
<svg class="icon icon-time" height="14" viewBox="0 0 16 16" width="14" xmlns="http://www.w3.org/2000/svg"><path d="m8-.0000003c-4.4 0-8 3.6-8 8 0 4.4000003 3.6 8.0000003 8 8.0000003 4.4 0 8-3.6 8-8.0000003 0-4.4-3.6-8-8-8zm0 14.4000003c-3.52 0-6.4-2.88-6.4-6.4000003 0-3.52 2.88-6.4 6.4-6.4 3.52 0 6.4 2.88 6.4 6.4 0 3.5200003-2.88 6.4000003-6.4 6.4000003zm.4-10.4000003h-1.2v4.8l4.16 2.5600003.64-1.04-3.6-2.1600003z"/></svg>
|
||||
<time class="mr-meta-date updated" datetime="{{ .Date }}">{{.Date.Format "January 02, 2006"}}</time>
|
||||
</div>
|
||||
</header>
|
||||
<div class="mr-loop-excerpt">
|
||||
<div class="mr-excerpt">
|
||||
{{ .Summary }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
{{ end }}
|
||||
|
||||
{{ partial "pagination.html" . }}
|
||||
</div>
|
||||
|
||||
{{ partial "sidebar.html" . }}
|
||||
{{ partial "footer.html" . }}
|
33
layouts/_default/single.html
Normal file
33
layouts/_default/single.html
Normal file
|
@ -0,0 +1,33 @@
|
|||
{{ partial "header.html" . }}
|
||||
|
||||
<div class="mr-content" id="main-content" role="main" itemprop="mainContentOfPage">
|
||||
<article class="post">
|
||||
<header class="entry-header clearfix">
|
||||
<h1 class="entry-title">{{ .Title }}</h1>
|
||||
<p class="mr-meta entry-meta">
|
||||
<svg class="icon icon-time" height="14" viewBox="0 0 16 16" width="14" xmlns="http://www.w3.org/2000/svg"><path d="m8-.0000003c-4.4 0-8 3.6-8 8 0 4.4000003 3.6 8.0000003 8 8.0000003 4.4 0 8-3.6 8-8.0000003 0-4.4-3.6-8-8-8zm0 14.4000003c-3.52 0-6.4-2.88-6.4-6.4000003 0-3.52 2.88-6.4 6.4-6.4 3.52 0 6.4 2.88 6.4 6.4 0 3.5200003-2.88 6.4000003-6.4 6.4000003zm.4-10.4000003h-1.2v4.8l4.16 2.5600003.64-1.04-3.6-2.1600003z"/></svg>
|
||||
<time class="entry-meta-date updated" datetime="{{ .Date }}">{{.Date.Format "January 02, 2006"}}</time>
|
||||
{{- if .Params.categories }}
|
||||
<span class="entry-meta-categories">
|
||||
<svg class="icon icon-category" height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m7 2l1 2h8v11h-16v-13z"/></svg>
|
||||
{{ range $index, $category := .Params.categories }}{{ if gt $index 0 }}, {{ end }}<a class="meta-categories" href="{{ "/categories/" | relLangURL }}{{ . | urlize | lower }}" rel="category">{{ . }}</a>{{ end }}</span>
|
||||
{{- end }}
|
||||
</p>
|
||||
</header>
|
||||
<div class="entry-content clearfix">
|
||||
{{ if .Params.thumbnail }}
|
||||
<figure class="entry-thumbnail">
|
||||
<img src="{{ .Params.thumbnail | absURL }}" alt="{{ .Title }}">
|
||||
</figure>
|
||||
{{ end }}
|
||||
{{ .Content }}
|
||||
</div>
|
||||
{{ partial "post_tags.html" . }}
|
||||
</article>
|
||||
{{ partial "authorbox.html" . }}
|
||||
{{ partial "post_nav.html" . }}
|
||||
{{ partial "comments.html" . }}
|
||||
</div>
|
||||
|
||||
{{ partial "sidebar.html" . }}
|
||||
{{ partial "footer.html" . }}
|
13
layouts/partials/authorbox.html
Normal file
13
layouts/partials/authorbox.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
{{ if .Site.Params.authorbox }}
|
||||
<div class="mr-author-box clearfix">
|
||||
<figure class="mr-author-box-avatar">
|
||||
<img alt="{{ .Site.Author.name }} avatar" src="{{ .Site.Author.avatar | absURL }}" class="avatar avatar-90 photo" height="90" width="90">
|
||||
</figure>
|
||||
<div class="mr-author-box-header">
|
||||
<span class="mr-author-box-name">About {{ .Site.Author.name }}</span>
|
||||
</div>
|
||||
<div class="mr-author-box-bio">
|
||||
{{ .Site.Author.bio }}
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
5
layouts/partials/comments.html
Normal file
5
layouts/partials/comments.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
{{ if and (not (eq .Site.DisqusShortname "")) (not .Params.disable_comments) }}
|
||||
<div id="mr-comments" class="mr-comments-wrap">
|
||||
{{ template "_internal/disqus.html" . }}
|
||||
</div>
|
||||
{{ end }}
|
9
layouts/partials/footer.html
Normal file
9
layouts/partials/footer.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
</div>
|
||||
<div class="mr-copyright-wrap">
|
||||
<div class="mr-container mr-container-inner clearfix">
|
||||
<p class="mr-copyright">© {{.Now.Format "2006"}} {{ .Site.Title }}. Based on <a href="//wordpress.org/themes/mh-magazine-lite/" target="_blank" rel="nofollow noopener noreferrer">MH Magazine lite</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- .mh-container-outer -->
|
||||
</body>
|
||||
</html>
|
42
layouts/partials/header.html
Normal file
42
layouts/partials/header.html
Normal file
|
@ -0,0 +1,42 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="no-js" lang="{{ .Site.LanguageCode | default "en-us" }}">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{ .Title }}</title>
|
||||
{{ with .Site.Params.description }}<meta name="description" content="{{ . }}">{{ end }}
|
||||
{{ .Hugo.Generator }}
|
||||
{{ if .Site.Params.opengraph }}{{ template "_internal/opengraph.html" . }}{{ end }}
|
||||
<link rel="dns-prefetch" href="//fonts.googleapis.com" />
|
||||
{{ if .RSSLink -}}<link rel="alternate" type="application/rss+xml" title="{{ .Site.Title }} Feed" href="{{ .RSSLink }}">{{- end }}
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:400,400italic,700,600" type="text/css" media="all" />
|
||||
<link rel="stylesheet" href="{{ .Site.BaseURL }}css/style.css" type="text/css" media="all" />
|
||||
<script type="text/javascript" src="{{ .Site.BaseURL }}js/jquery.js"></script>
|
||||
<script type="text/javascript" src="{{ .Site.BaseURL }}js/scripts.js"></script>
|
||||
{{ "<!--[if lt IE 9]>" | safeHTML }}
|
||||
<script src="{{ .Site.BaseURL }}js/css3-mediaqueries.js"></script>
|
||||
{{ "<![endif]-->" | safeHTML }}
|
||||
</head>
|
||||
<body id="mr-mobile" class="home blog {{ if (.Site.Params.leftsidebar) or (.Params.leftsidebar) }}mr-left-sb{{ else }}mr-right-sb{{ end }}" itemscope="itemscope" itemtype="http://schema.org/WebPage">
|
||||
<div class="mr-container mr-container-outer">
|
||||
<div class="mr-header-mobile-nav clearfix"></div>
|
||||
<header class="mr-header" itemscope="itemscope" itemtype="http://schema.org/WPHeader">
|
||||
<div class="mr-container mr-container-inner mr-row clearfix">
|
||||
<div class="mr-custom-header clearfix">
|
||||
<div class="mr-site-identity">
|
||||
<div class="mr-site-logo" role="banner" itemscope="itemscope" itemtype="http://schema.org/Brand">
|
||||
<div class="mr-header-text">
|
||||
<a class="mr-header-text-link" href="{{ .Site.BaseURL }}" title="{{ .Site.Title }}" rel="home">
|
||||
<h1 class="mr-header-title">{{ .Site.Title }}</h1>
|
||||
{{ with .Site.Params.subtitle -}}<h2 class="mr-header-tagline">{{ . }}</h2>{{- end }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mr-main-nav-wrap">
|
||||
{{ partial "menu.html" . }}
|
||||
</div>
|
||||
</header>
|
||||
<div class="mr-wrapper clearfix">
|
11
layouts/partials/menu.html
Normal file
11
layouts/partials/menu.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
<nav class="mr-navigation mr-main-nav mr-container mr-container-inner clearfix" itemscope="itemscope" itemtype="http://schema.org/SiteNavigationElement">
|
||||
<div class="menu">
|
||||
<ul>
|
||||
{{ if .Site.Menus.main }}
|
||||
{{ range sort .Site.Menus.main }}
|
||||
<li class="page_item"><a href="{{ .URL }}">{{ .Name | upper }}</a></li>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
11
layouts/partials/pagination.html
Normal file
11
layouts/partials/pagination.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
{{ if or (.Paginator.HasPrev) (.Paginator.HasNext) }}
|
||||
<div class="mr-loop-pagination clearfix">
|
||||
{{ if .Paginator.HasPrev }}
|
||||
<a class="page-numbers" href="{{ .Paginator.Prev.URL }}">«</a>
|
||||
{{ end }}
|
||||
<span class="page-numbers current">{{ .Paginator.PageNumber }}/{{ .Paginator.TotalPages }}</span>
|
||||
{{ if .Paginator.HasNext }}
|
||||
<a class="page-numbers" href="{{ .Paginator.Next.URL }}">»</a>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
16
layouts/partials/post_nav.html
Normal file
16
layouts/partials/post_nav.html
Normal file
|
@ -0,0 +1,16 @@
|
|||
{{ if .Site.Params.post_navigation }}
|
||||
{{ if or (.Prev) (.Next) }}
|
||||
<nav class="mr-post-nav mr-row clearfix" itemscope="itemscope" itemtype="http://schema.org/SiteNavigationElement">
|
||||
{{ if .Prev }}
|
||||
<div class="mr-col-1-2 mr-post-nav-item mr-post-nav-prev">
|
||||
<a href="{{.Prev.Permalink}}" rel="prev"><span>«Previous</span><p>{{.Prev.Title}}</p></a>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ if .Next }}
|
||||
<div class="mr-col-1-2 mr-post-nav-item mr-post-nav-next">
|
||||
<a href="{{.Next.Permalink}}" rel="next"><span>Next»</span><p>{{.Next.Title}}</p></a>
|
||||
</div>
|
||||
{{ end }}
|
||||
</nav>
|
||||
{{ end }}
|
||||
{{ end }}
|
10
layouts/partials/post_tags.html
Normal file
10
layouts/partials/post_tags.html
Normal file
|
@ -0,0 +1,10 @@
|
|||
{{- if .Params.tags }}
|
||||
<div class="entry-tags clearfix">
|
||||
<svg class="icon icon-tag" width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="m4.73135 3.3795002q0-.5597-.39604-.9557-.39604-.3961-.95577-.3961-.55974 0-.95578.3961-.39604.396-.39604.9557 0 .5598.39604.9558.39604.3961.95578.3961.55973 0 .95577-.3961.39604-.396.39604-.9558zm11.26865 6.0832q0 .5596998-.39076.9504998l-5.18548 5.196q-.41188.3908-.9610504.3908-.55974 0-.9505-.3908l-7.5511496-7.5616998q-.40132-.3907-.68119-1.0666-.27987-.6759-.27987-1.2357v-4.3934q0-.54920004.40132-.95050004.40132-.4013.9505-.4013h4.39339q.55974 0 1.23565.2799.67591.2798 1.07723.6812l7.55115 7.54060004q.39076.4118.39076.961z"/></svg>
|
||||
<ul>
|
||||
{{ range .Params.tags -}}
|
||||
<li><a href="/tags/{{ . | urlize }}/" rel="tag">{{ . }}</a></li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</div>
|
||||
{{- end }}
|
6
layouts/partials/sidebar.html
Normal file
6
layouts/partials/sidebar.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
<aside class="mr-sidebar" itemscope="itemscope" itemtype="http://schema.org/WPSideBar">
|
||||
{{ partial "widgets/search.html" . }}
|
||||
{{ partial "widgets/recent.html" . }}
|
||||
{{ partial "widgets/categories.html" . }}
|
||||
{{ partial "widgets/taglist.html" . }}
|
||||
</aside>
|
14
layouts/partials/widgets/categories.html
Normal file
14
layouts/partials/widgets/categories.html
Normal file
|
@ -0,0 +1,14 @@
|
|||
{{ if .Site.Params.widgets.categories }}
|
||||
{{ if isset .Site.Taxonomies "categories" }}
|
||||
{{ if not (eq (len .Site.Taxonomies.categories) 0) }}
|
||||
<div class="mr-widget widget_categories">
|
||||
<h4 class="mr-widget-title"><span class="mr-widget-title-inner">Categories</span></h4>
|
||||
<ul>
|
||||
{{ range $name, $items := .Site.Taxonomies.categories }}
|
||||
<li class="cat-item"><a href="{{ $.Site.BaseURL }}categories/{{ $name | urlize | lower }}">{{ $name | title }}</a></li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
10
layouts/partials/widgets/recent.html
Normal file
10
layouts/partials/widgets/recent.html
Normal file
|
@ -0,0 +1,10 @@
|
|||
{{ if .Site.Params.widgets.recent_articles }}
|
||||
<div class="mr-widget widget_recent_entries">
|
||||
<h4 class="mr-widget-title"><span class="mr-widget-title-inner">Recent Posts</span></h4>
|
||||
<ul>
|
||||
{{ range first 10 .Site.Pages }}
|
||||
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</div>
|
||||
{{ end }}
|
12
layouts/partials/widgets/search.html
Normal file
12
layouts/partials/widgets/search.html
Normal file
|
@ -0,0 +1,12 @@
|
|||
{{ if .Site.Params.widgets.search }}
|
||||
<div class="mr-widget widget_search">
|
||||
<form class="search-form" role="search" method="get" action="//google.com/search">
|
||||
<label>
|
||||
<span class="screen-reader-text">Search for:</span>
|
||||
<input type="search" class="search-field" placeholder="Search..." value="" name="q">
|
||||
</label>
|
||||
<input class="search-submit" type="submit" value="Search">
|
||||
<input type="hidden" name="sitesearch" value="{{ .Site.BaseURL }}" />
|
||||
</form>
|
||||
</div>
|
||||
{{ end }}
|
14
layouts/partials/widgets/taglist.html
Normal file
14
layouts/partials/widgets/taglist.html
Normal file
|
@ -0,0 +1,14 @@
|
|||
{{ if .Site.Params.widgets.tags }}
|
||||
{{ if isset .Site.Taxonomies "tags" }}
|
||||
{{ if not (eq (len .Site.Taxonomies.tags) 0) }}
|
||||
<div class="mr-widget widget_tag_cloud">
|
||||
<h4 class="mr-widget-title"><span class="mr-widget-title-inner">Tags</span></h4>
|
||||
<div class="tagcloud">
|
||||
{{ range $name, $items := .Site.Taxonomies.tags }}
|
||||
<a href="{{ $.Site.BaseURL }}tags/{{ $name | urlize | lower }}" class="tag-link" title="{{ $name }}" style="font-size: 12px;">{{ $name }}</a>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
2328
static/css/style.css
Normal file
2328
static/css/style.css
Normal file
File diff suppressed because it is too large
Load diff
BIN
static/img/avatar.png
Normal file
BIN
static/img/avatar.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 1.1 KiB |
BIN
static/img/placeholder.png
Normal file
BIN
static/img/placeholder.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 4.6 KiB |
1
static/js/css3-mediaqueries.js
Normal file
1
static/js/css3-mediaqueries.js
Normal file
File diff suppressed because one or more lines are too long
6
static/js/jquery.js
vendored
Normal file
6
static/js/jquery.js
vendored
Normal file
File diff suppressed because one or more lines are too long
40
static/js/scripts.js
Normal file
40
static/js/scripts.js
Normal file
File diff suppressed because one or more lines are too long
18
theme.toml
Normal file
18
theme.toml
Normal file
|
@ -0,0 +1,18 @@
|
|||
name = "Mainroad"
|
||||
license = "GPLv2"
|
||||
licenselink = "//github.com/vimux/mainroad/blob/master/LICENSE.md"
|
||||
description = "Mainroad is a responsive, clean and content-focused Hugo theme."
|
||||
homepage = "//github.com/vimux/mainroad/"
|
||||
tags = ["blog", "responsive", "widgets", "rss", "disqus", "wordpress"]
|
||||
features = ["blog", "responsive", "widgets", "rss", "disqus", "wordpress"]
|
||||
min_version = 0.17
|
||||
|
||||
[author]
|
||||
name = "Vimux"
|
||||
homepage = "//github.com/vimux"
|
||||
|
||||
# If porting an existing theme
|
||||
[original]
|
||||
name = "MH Magazine lite"
|
||||
homepage = "//wordpress.org/themes/mh-magazine-lite/"
|
||||
repo = "//themes.trac.wordpress.org/browser/mh-magazine-lite/2.5.6"
|
Loading…
Add table
Reference in a new issue