diff --git a/config.toml b/config.toml index 85612b0..bad66f6 100644 --- a/config.toml +++ b/config.toml @@ -1,7 +1,7 @@ baseURL = "http://www.thehellings.com/" languageCode = "en-us" title = "The Hellings" -theme = "Mainroad" +theme = "Gregroad" enableEmoji = true enableRobotsTXT = true diff --git a/themes/Gregroad/.browserslistrc b/themes/Gregroad/.browserslistrc new file mode 100644 index 0000000..2000ee5 --- /dev/null +++ b/themes/Gregroad/.browserslistrc @@ -0,0 +1,4 @@ +> 0.25% +not dead +IE >= 11 +iOS >= 7 diff --git a/themes/Gregroad/.editorconfig b/themes/Gregroad/.editorconfig new file mode 100644 index 0000000..576a2a9 --- /dev/null +++ b/themes/Gregroad/.editorconfig @@ -0,0 +1,19 @@ +# editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = tab +end_of_line = lf +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false + +[*.{json,yaml,yml,toml,md,babelrc,eslintrc,postcssrc,stylelintrc}] +indent_style = space +indent_size = 2 + +[layouts/**.{html,svg}] +insert_final_newline = false diff --git a/themes/Gregroad/.eslintrc b/themes/Gregroad/.eslintrc new file mode 100644 index 0000000..c091af7 --- /dev/null +++ b/themes/Gregroad/.eslintrc @@ -0,0 +1,9 @@ +{ + "extends": "airbnb-base/legacy", + "rules": { + "indent": [2, "tab"], + "no-tabs": 0, + "no-unused-vars": 0, + "no-shadow-restricted-names": 0 + } +} diff --git a/themes/Gregroad/.postcssrc b/themes/Gregroad/.postcssrc new file mode 100644 index 0000000..7d88406 --- /dev/null +++ b/themes/Gregroad/.postcssrc @@ -0,0 +1,7 @@ +{ + "plugins": { + "autoprefixer": { + cascade: false + } + } +} diff --git a/themes/Gregroad/.stylelintrc b/themes/Gregroad/.stylelintrc new file mode 100644 index 0000000..433e93f --- /dev/null +++ b/themes/Gregroad/.stylelintrc @@ -0,0 +1,319 @@ +{ + "plugins": [ + "stylelint-order" + ], + "rules": { + "at-rule-empty-line-before": [ + "always", + { + "except": [ + "blockless-after-same-name-blockless", + "first-nested" + ], + "ignore": [ + "after-comment" + ] + } + ], + "at-rule-name-case": "lower", + "at-rule-name-space-after": "always-single-line", + "at-rule-semicolon-newline-after": "always", + "block-closing-brace-newline-after": "always", + "block-closing-brace-empty-line-before": "never", + "block-no-empty": true, + "block-opening-brace-newline-after": "always-multi-line", + "color-hex-case": "lower", + "color-hex-length": "short", + "color-no-invalid-hex": true, + "comment-no-empty": true, + "declaration-bang-space-after": "never", + "declaration-bang-space-before": "always", + "declaration-block-no-duplicate-properties": [ + true, + { + "ignore": [ + "consecutive-duplicates-with-different-values" + ] + } + ], + "declaration-block-no-shorthand-property-overrides": true, + "declaration-block-semicolon-newline-after": "always-multi-line", + "declaration-block-semicolon-space-after": "always-single-line", + "declaration-block-semicolon-space-before": "never", + "declaration-block-single-line-max-declarations": 1, + "declaration-block-trailing-semicolon": "always", + "declaration-colon-newline-after": "always-multi-line", + "declaration-colon-space-after": "always-single-line", + "declaration-colon-space-before": "never", + "font-family-no-duplicate-names": true, + "function-calc-no-unspaced-operator": true, + "function-comma-newline-after": "always-multi-line", + "function-comma-space-after": "always-single-line", + "function-comma-space-before": "never", + "function-linear-gradient-no-nonstandard-direction": true, + "function-max-empty-lines": 0, + "function-name-case": "lower", + "function-parentheses-newline-inside": "always-multi-line", + "function-parentheses-space-inside": "never-single-line", + "function-whitespace-after": "always", + "indentation": "tab", + "keyframe-declaration-no-important": true, + "length-zero-no-unit": true, + "max-empty-lines": 1, + "media-feature-colon-space-after": "always", + "media-feature-colon-space-before": "never", + "media-feature-name-case": "lower", + "media-feature-name-no-unknown": true, + "media-feature-parentheses-space-inside": "never", + "media-feature-range-operator-space-after": "always", + "media-feature-range-operator-space-before": "always", + "media-query-list-comma-newline-after": "always-multi-line", + "media-query-list-comma-space-after": "always-single-line", + "media-query-list-comma-space-before": "never", + "no-empty-source": true, + "no-eol-whitespace": true, + "no-extra-semicolons": true, + "no-invalid-double-slash-comments": true, + "no-missing-end-of-source-newline": true, + "number-no-trailing-zeros": true, + "property-case": "lower", + "property-no-unknown": true, + "selector-attribute-brackets-space-inside": "never", + "selector-attribute-operator-space-after": "never", + "selector-attribute-operator-space-before": "never", + "selector-combinator-space-after": "always", + "selector-combinator-space-before": "always", + "selector-descendant-combinator-no-non-space": true, + "selector-list-comma-newline-after": "always", + "selector-list-comma-space-before": "never", + "selector-pseudo-class-case": "lower", + "selector-pseudo-class-no-unknown": true, + "selector-pseudo-class-parentheses-space-inside": "never", + "selector-pseudo-element-case": "lower", + "selector-pseudo-element-colon-notation": "double", + "selector-pseudo-element-no-unknown": true, + "selector-type-case": "lower", + "selector-type-no-unknown": true, + "shorthand-property-no-redundant-values": true, + "string-no-newline": true, + "unit-case": "lower", + "unit-no-unknown": true, + "value-list-comma-newline-after": "always-multi-line", + "value-list-comma-space-after": "always-single-line", + "value-list-comma-space-before": "never", + "value-list-max-empty-lines": 0, + "order/properties-order": [ + "position", + "top", + "right", + "bottom", + "left", + "z-index", + "box-sizing", + "display", + "flex", + "flex-align", + "flex-basis", + "flex-direction", + "flex-wrap", + "flex-flow", + "flex-shrink", + "flex-grow", + "flex-wrap", + "align-content", + "align-items", + "align-self", + "justify-content", + "order", + "float", + "width", + "min-width", + "max-width", + "height", + "min-height", + "max-height", + "padding", + "padding-top", + "padding-right", + "padding-bottom", + "padding-left", + "margin", + "margin-top", + "margin-right", + "margin-bottom", + "margin-left", + "overflow", + "overflow-x", + "overflow-y", + "-webkit-overflow-scrolling", + "-ms-overflow-x", + "-ms-overflow-y", + "-ms-overflow-style", + "columns", + "column-count", + "column-fill", + "column-gap", + "column-rule", + "column-rule-width", + "column-rule-style", + "column-rule-color", + "column-span", + "column-width", + "orphans", + "widows", + "clip", + "clear", + "font", + "font-family", + "font-size", + "font-style", + "font-weight", + "font-variant", + "font-size-adjust", + "font-stretch", + "font-effect", + "font-emphasize", + "font-emphasize-position", + "font-emphasize-style", + "font-smooth", + "src", + "hyphens", + "line-height", + "color", + "text-align", + "text-align-last", + "text-emphasis", + "text-emphasis-color", + "text-emphasis-style", + "text-emphasis-position", + "text-decoration", + "text-indent", + "text-justify", + "text-outline", + "-ms-text-overflow", + "text-overflow", + "text-overflow-ellipsis", + "text-overflow-mode", + "text-shadow", + "text-transform", + "text-wrap", + "-webkit-text-size-adjust", + "-ms-text-size-adjust", + "letter-spacing", + "-ms-word-break", + "word-break", + "word-spacing", + "-ms-word-wrap", + "word-wrap", + "overflow-wrap", + "tab-size", + "white-space", + "vertical-align", + "direction", + "unicode-bidi", + "list-style", + "list-style-position", + "list-style-type", + "list-style-image", + "pointer-events", + "-ms-touch-action", + "touch-action", + "cursor", + "visibility", + "zoom", + "table-layout", + "empty-cells", + "caption-side", + "border-spacing", + "border-collapse", + "content", + "quotes", + "counter-reset", + "counter-increment", + "resize", + "user-select", + "nav-index", + "nav-up", + "nav-right", + "nav-down", + "nav-left", + "background", + "background-color", + "background-image", + "filter", + "background-repeat", + "background-attachment", + "background-position", + "background-position-x", + "background-position-y", + "background-clip", + "background-origin", + "background-size", + "border", + "border-color", + "border-style", + "border-width", + "border-top", + "border-top-color", + "border-top-style", + "border-top-width", + "border-right", + "border-right-color", + "border-right-style", + "border-right-width", + "border-bottom", + "border-bottom-color", + "border-bottom-style", + "border-bottom-width", + "border-left", + "border-left-color", + "border-left-style", + "border-left-width", + "border-radius", + "border-top-left-radius", + "border-top-right-radius", + "border-bottom-right-radius", + "border-bottom-left-radius", + "border-image", + "border-image-source", + "border-image-slice", + "border-image-width", + "border-image-outset", + "border-image-repeat", + "outline", + "outline-width", + "outline-style", + "outline-color", + "outline-offset", + "box-shadow", + "opacity", + "-ms-interpolation-mode", + "page-break-after", + "page-break-before", + "page-break-inside", + "transition", + "transition-delay", + "transition-timing-function", + "transition-duration", + "transition-property", + "transform", + "transform-origin", + "perspective", + "appearance", + "animation", + "animation-name", + "animation-duration", + "animation-play-state", + "animation-timing-function", + "animation-delay", + "animation-iteration-count", + "animation-direction", + "animation-fill-mode", + "quotes", + "will-change", + "fill", + "fill-rule", + "stroke" + ] + } +} diff --git a/themes/Gregroad/CONTRIBUTING.md b/themes/Gregroad/CONTRIBUTING.md new file mode 100644 index 0000000..161ecee --- /dev/null +++ b/themes/Gregroad/CONTRIBUTING.md @@ -0,0 +1,125 @@ +# Contributing to Mainroad + +**Mainroad** welcomes contributions and corrections. Before contributing, please make sure you have read the guidelines +below. If you're a newcomer to open source and you haven't contributed to other projects or used +[Git](https://git-scm.com/) before, you should make yourself familiar before proceeding. + +## Issues + +The [issue tracker](https://github.com/vimux/mainroad/issues) is the preferred channel for bug reports and features +requests, but please respect the following restrictions: + +### General requirements + +* Issue must be written in English. +* Please **do not** combine a few problems or feature requests in one issue. Create separate issues if needed. +* Please **do not** create an issue that contains only title. Write a clear title and useful description. +* Please **do not** use the issue tracker for personal support requests. +* Please **do not** post comments consisting solely of "+1" or emoji. The project maintainer reserve the right to delete +such comments. Use +[GitHub's reactions feature](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments) instead. +* Search first before filing a new issue. Please check existing open or recently closed issues to make sure somebody +else hasn't already reported the issue. + +### Reporting bugs + +When creating a new bug issue make sure to include the following information: + +* Your environment e.g. OS version, Hugo version, theme is up to date? Anything unusual about your environment or +deployment. +* Specify the exact steps to reproduce the bug in as many details as possible with code examples. Include links to files +or demo projects, or copy/pasteable snippets, which you use in those examples. +* Any message or error you get from Hugo, if you do. +* A screenshot of any visual bug. + +Please, take in consideration the next template to report your bug: + +> **Hugo version**\ +> _Run `hugo version` and paste output here._ +> +> **Theme is up to date?**\ +> _No | Yes_ +> +> **Expected behavior**\ +> _A short and expressive description of what behavior you're expecting._ +> +> **Current behavior**\ +> _A short sentence explaining what's actually happening, possibly containing screenshots._ +> +> **Steps to reproduce / Code to reproduce**\ +> _A step by step description of how to trigger this bug. / Provide link to a demo project which reproduces this bug._ +> +> **Additional info**\ +> _Anything unusual about your environment or deployment process? Anything else do we need to know? Optional._ + +**Note:** If you find a **Closed** issue that seems like it is the same bug that you're experiencing, open a new issue +and include a link to the original issue in the body of your new one. + +### Proposing features + +* Explain the proposed feature, what it should do, why it is useful, and alternatives considered if possible. Please +note that the project maintainer may close this issue or ask you to create a Pull Request if this is not something that +the project maintainer sees as a sufficiently high priority. + +Following these guidelines helps maintainer and the community understand your suggestion and find related suggestions. + +## Pull Requests (PR) + +**Please ask first** before embarking on any significant pull request (e.g. implementing features or refactoring code), +otherwise, you risk spending a lot of time working on something that the project maintainer might not want to merge into +the project. + +Please respect our Pull Request Acceptance Criteria. For larger changes, you will likely receive multiple rounds of +comments and it may take some time to complete. + +### Pull Request Acceptance Criteria + +* Keep the change in a single PR as small as possible +* 1 PR = 1 FIX or FEATURE (do not combine things, send separate PR if needed) + * PR with irrelevant changes won't be merged. If you do want to fix formatting or style, do that in a separate PR +* Use a clear and descriptive branch name (e.g. **NOT** "patch-1" or "update") +* Don't create a Pull Request from master branch +* Provide a reasonable PR title and description + * PR must be written in English + * If the PR changes the UI it should include before-and-after screenshots or a link to a video +* Keep PR up to date with upstream/master +* Pay attention to any automated CI failures reported in the Pull Request +* PR solves a common use case that several users will need in their real-life projects, not only your specific problems +* If you've added or modify SVG, ensure that each SVG file: + * Be less than 2048 bytes + * Be minified to a single line with no formatting + * Not contain any JS or CSS section inside it + * Not contain any additional transformations (matrix, translate, scale) + * Сompatible with [GPLv2 License](LICENSE.md) +* Maintain clean commit history and use meaningful commit messages. Pull Requests with messy commit history (with +commit messages like "update", "another update", etc) are difficult to review and won't be merged, even if the changes +are good enough +* Be prepared to answer questions and make code changes. The project maintainer expect you to be reasonably responsive +to those feedback, otherwise the PR will be closed after 2-4 weeks of inactivity + +### Pull Request Contribution Prerequisites + +* You have Node & npm installed +* You have Hugo installed at v0.48.0+ +* You are familiar with Git + +### Pull Request Process + +1. Fork the repository +1. Clone down the repository to your local system +1. Run `npm i` in the repository root +1. Create a new *dedicated branch* with descriptive name from `master` +1. Make your change and commit to the new branch from the previous step + 1. Write a clear commit message + 1. If you've added code that need documentation, update the README.md +1. Make sure your code lints (`npm test`) +1. Push to your fork +1. Submit a Pull Request (PR) to the upstream + +--- + +**⚠️ IMPORTANT: No guarantees can be made that your pull request will be accepted.** + +## License + +By contributing to Mainroad, you agree that your contributions will be licensed under [GPLv2 License](LICENSE.md). diff --git a/themes/Gregroad/LICENSE.md b/themes/Gregroad/LICENSE.md new file mode 100644 index 0000000..5544f2d --- /dev/null +++ b/themes/Gregroad/LICENSE.md @@ -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. diff --git a/themes/Gregroad/README.md b/themes/Gregroad/README.md new file mode 100644 index 0000000..e1e051d --- /dev/null +++ b/themes/Gregroad/README.md @@ -0,0 +1,194 @@ +# Mainroad + +**Mainroad** is a responsive, simple, clean and content-focused [Hugo](https://gohugo.io/) theme based on the +[MH Magazine lite](https://wordpress.org/themes/mh-magazine-lite/) theme. + +**[Demo](https://mainroad-demo.netlify.app/)** • **[Docs](https://mainroad-demo.netlify.app/docs/)** + +![screenshot](https://raw.githubusercontent.com/Vimux/Mainroad/master/images/screenshot.png) + +**Features:** + ++ Responsive design ++ Main & secondary menus ++ Widgetized sidebar ++ Translations. Over 15 languages and counting ++ Configurable theme settings (sidebar position, author box, post navigation, highlight color) via `config.toml` ++ Hugo internal templates (Open Graph, Schema, Twitter Cards, Disqus, Google Analytics) ++ Wide cross-browser compatibility + + *Desktop: IE11+, Chrome, Firefox, Safari* + + *Mobile: Android browser (on Android 4.4+), Safari (on iOS 7+), Google Chrome, Opera mini* ++ Custom Google Fonts support, MathJax, Table of Contents, SVG icons and much more… + +## Installation + +*Before starting, please be sure that you have +[installed Hugo](https://gohugo.io/getting-started/quick-start/#step-1-install-hugo) and +[created a new site](https://gohugo.io/getting-started/quick-start/#step-2-create-a-new-site). After that, you are ready +to install **Mainroad**.* + +From your project's root directory, run: + +``` +git clone https://github.com/vimux/mainroad.git themes/mainroad +``` + +Or, if you don't plan to make any significant changes but want to track and update the theme, you can add it as a git +submodule via the following command: + +``` +git submodule add https://github.com/vimux/mainroad.git themes/mainroad +``` + +Next, open `config.toml` in the base of the Hugo site and ensure the theme option is set to `mainroad`: + +``` +theme = "mainroad" +``` + +## Configuration + +### Config.toml example + +```toml +baseurl = "/" +title = "Mainroad" +languageCode = "en-us" +paginate = "10" # Number of posts per page +theme = "mainroad" +disqusShortname = "" # Enable Disqus comments by entering your Disqus shortname +googleAnalytics = "" # Enable Google Analytics by entering your tracking id + +[Author] # Used in authorbox + 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] + description = "John Doe's Personal blog about everything" # Site description. Used in meta description + copyright = "John Doe" # Footer copyright holder, otherwise will use site title + opengraph = true # Enable OpenGraph if true + schema = true # Enable Schema + twitter_cards = true # Enable Twitter Cards if true + readmore = false # Show "Read more" button in list if true + authorbox = true # Show authorbox at bottom of pages if true + toc = true # Enable Table of Contents + pager = true # Show pager navigation (prev/next links) at the bottom of pages if true + post_meta = ["author", "date", "categories", "translations"] # Order of post meta information + mainSections = ["post", "blog", "news"] # Specify section pages to show on home page and the "Recent articles" widget + dateformat = "2006-01-02" # Change the format of dates + mathjax = true # Enable MathJax + mathjaxPath = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js" # Specify MathJax path + mathjaxConfig = "TeX-AMS-MML_HTMLorMML" # Specify MathJax config + googleFontsLink = "https://fonts.googleapis.com/css?family=Open+Sans:400,400i,700" # Load Google Fonts + customCSS = ["css/custom.css"] # Include custom CSS files + customJS = ["js/custom.js"] # Include custom JS files + + # DEPRECATED PARAMS + subtitle = "" # Deprecated in favor of .Site.Params.logo.subtitle + highlightColor = "" # Deprecated in favor of .Site.Params.style.vars.highlightColor + +[Params.style.vars] + highlightColor = "#e22d30" # Override highlight color + + # Override font-family sets + # Take care of different quotes OR escaping symbols in these params if necessary + fontFamilyPrimary = "'Open Sans', Helvetica, Arial, sans-serif" + # Secondary font-family set responsible for pre, code, kbd, and samp tags font + fontFamilySecondary = "SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace" + +[Params.logo] + image = "img/placeholder.png" # Logo image. Path relative to "static" + title = "Mainroad" # Logo title, otherwise will use site title + subtitle = "Just another site" # Logo subtitle + +[Params.thumbnail] + visibility = ["list", "post"] # Control thumbnail visibility + +[Params.sidebar] + home = "right" # Configure layout for home page + list = "left" # Configure layout for list pages + single = false # Configure layout for single pages + # Enable widgets in given order + widgets = ["search", "recent", "categories", "taglist", "social", "languages"] + # alternatively "ddg-search" can be used, to search via DuckDuckGo + # widgets = ["ddg-search", "recent", "categories", "taglist", "social", "languages"] + +[Params.widgets] + recent_num = 5 # Set the number of articles in the "Recent articles" widget + categories_counter = false # Enable counter for each category in "Categories" widget + tags_counter = false # Enable counter for each tag in "Tags" widget + +[Params.widgets.social] + # Enable parts of social widget + facebook = "username" + twitter = "username" + instagram = "username" + linkedin = "username" + telegram = "username" + github = "username" + gitlab = "username" + bitbucket = "username" + email = "example@example.com" + +# Custom social links +[[Params.widgets.social.custom]] + title = "Youtube" + url = "https://youtube.com/user/username" + icon = "youtube.svg" # Optional. Path relative to "layouts/partials" + +[[Params.widgets.social.custom]] + title = "My Home Page" + url = "https://example.com" +``` + +**Do not copy example config as-is**. Use only those parameters that you need. + +For more information about all available standard configuration settings, please read +[All Hugo Configuration Settings](https://gohugo.io/getting-started/configuration/#all-configuration-settings). + +### Front Matter example + +```yaml +--- +# Common-Defined params +title: "Example article title" +date: "2017-08-21" +description: "Example article description" +categories: + - "Category 1" + - "Category 2" +tags: + - "Test" + - "Another test" +menu: main # Optional, add page to a menu. Options: main, side, footer + +# Theme-Defined params +thumbnail: "img/placeholder.png" # Thumbnail image +lead: "Example lead - highlighted near the title" # Lead text +comments: false # Enable Disqus comments for specific page +authorbox: true # Enable authorbox for specific page +pager: true # Enable pager navigation (prev/next) for specific page +toc: true # Enable Table of Contents for specific page +mathjax: true # Enable MathJax for specific page +sidebar: "right" # Enable sidebar (on the right side) per page +widgets: # Enable sidebar widgets in given order per page + - "search" + - "recent" + - "taglist" +--- +``` + +For more information about all available standard front matter variables, please read +[Hugo Front Matter](https://gohugo.io/content-management/front-matter). + +## Contributing + +Have you found a bug or got an idea for a new feature? Feel free to use the +[issue tracker](https://github.com/Vimux/mainroad/issues) to let me know. Or make directly a +[pull request](https://github.com/Vimux/mainroad/pulls), but please respect the following +[contributing guide](https://github.com/Vimux/mainroad/blob/master/CONTRIBUTING.md). + +## License + +This theme is released under the [GPLv2 license](https://github.com/Vimux/mainroad/blob/master/LICENSE.md). diff --git a/themes/Gregroad/archetypes/default.md b/themes/Gregroad/archetypes/default.md new file mode 100644 index 0000000..b2c51de --- /dev/null +++ b/themes/Gregroad/archetypes/default.md @@ -0,0 +1,10 @@ +--- +title: "{{ replace .TranslationBaseName '-' ' ' | title }}" +description: "" +date: "{{ .Date }}" +thumbnail: "" +categories: + - "" +tags: + - "" +--- diff --git a/themes/Gregroad/assets/css/style.css b/themes/Gregroad/assets/css/style.css new file mode 100644 index 0000000..be3bb1d --- /dev/null +++ b/themes/Gregroad/assets/css/style.css @@ -0,0 +1,1330 @@ +{{- $highlightColor := .Site.Params.style.vars.highlightColor | default (.Site.Params.highlightColor | default "#e22d30") -}} + +{{- $fontSans := `"Open Sans", Helvetica, Arial, sans-serif` -}} +{{- $fontMono := `SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace` -}} +{{- $fontFamilyPrimary := .Site.Params.style.vars.fontFamilyPrimary | default $fontSans -}} +{{- $fontFamilySecondary := .Site.Params.style.vars.fontFamilySecondary | default $fontMono -}} + +*, +*::before, +*::after { + box-sizing: border-box; +} + +article, +aside, +dialog, +figcaption, +figure, +footer, +header, +hgroup, +main, +nav, +section { + display: block; +} + +:focus::-webkit-input-placeholder { + color: transparent; +} + +:focus::-moz-placeholder { + color: transparent; +} + +:focus:-moz-placeholder { + color: transparent; +} + +:focus:-ms-input-placeholder { + color: transparent; +} + +/* Structure */ +html { + font-size: 100%; + -ms-text-size-adjust: none; + -webkit-text-size-adjust: none; +} + +body { + margin: 0; + font-family: {{ $fontFamilyPrimary }}; + font-size: 14px; + font-size: .875rem; + line-height: 1.6; + word-wrap: break-word; + background: #f7f7f7; + -webkit-font-smoothing: antialiased; +} + +.container { + position: relative; + width: 100%; + max-width: 1080px; + margin: 0 auto; +} + +.container--outer { + margin: 25px auto; + box-shadow: 0 0 10px rgba(50, 50, 50, .17); +} + +.wrapper { + padding: 25px; + background: #fff; +} + +.flex { + display: -webkit-flex; + display: flex; +} + +.primary { + -webkit-flex: 1 0 65.83%; + flex: 1 0 65.83%; + -webkit-order: 1; + order: 1; + min-width: 0; +} + +.sidebar { + -webkit-flex: 1 0 31.66%; + flex: 1 0 31.66%; + -webkit-order: 2; + order: 2; + min-width: 0; + margin: 0 0 0 2.5%; +} + +.sidebar--left { + -webkit-order: 0; + order: 0; + margin: 0 2.5% 0 0; +} + +.clearfix { + display: block; +} + +.clearfix::after { + display: block; + height: 0; + padding: 0; + margin: 0; + clear: both; + line-height: 0; + visibility: hidden; + content: ""; +} + +input, +button, +select, +optgroup, +textarea { + margin: 0; + font-family: inherit; + font-size: inherit; + line-height: inherit; +} + +/* Button */ +.btn { + padding: 5px 10px; + font-weight: 700; + color: #fff; + white-space: pre-line; + background: #2a2a2a; +} + +.btn:hover { + color: #fff; + background: {{ $highlightColor }}; +} + +/* Animation */ +.menu__item, +.btn { + transition: background-color .25s ease-out; +} + +/* Typography */ +h1, +h2, +h3, +h4, +h5, +h6 { + margin: 0 0 20px; + margin: 0 0 1.25rem; + font-weight: 700; + line-height: 1.3; + color: #000; +} + +h1 { + font-size: 32px; + font-size: 2rem; +} + +h2 { + font-size: 24px; + font-size: 1.5rem; +} + +h3 { + font-size: 20px; + font-size: 1.25rem; +} + +h4 { + font-size: 18px; + font-size: 1.125rem; +} + +h5 { + font-size: 16px; + font-size: 1rem; +} + +h6 { + font-size: 16px; + font-size: 1rem; +} + +a { + color: #000; + text-decoration: none; +} + +a:hover { + color: {{ $highlightColor }}; +} + +hr { + margin: 0 0 20px; + border: 0; + border-top: 1px solid #dadada; +} + +p { + margin: 0 0 20px; + margin: 0 0 1.25rem; +} + +b, +strong { + font: inherit; + font-weight: 700; +} + +i, +em { + font: inherit; + font-style: italic; +} + +ol, +ul { + padding: 0; + margin: 0; +} + +small { + font-size: 12px; + font-size: .75rem; +} + +mark { + background-color: #fd5; +} + +figure { + margin: 0 0 20px; + margin: 0 0 1.25rem; +} + +figcaption { + margin-top: 4px; + margin-top: .25rem; + color: #666; +} + +figcaption h4 { + margin: 0; + color: inherit; +} + +pre, +code, +kbd, +samp { + font-family: {{ $fontFamilySecondary }}; + font-size: inherit; +} + +pre, +code { + background-color: #f5f5f5; + border: 1px solid #ebebeb; +} + +code { + padding: 0 5px; + color: #c33; +} + +pre { + display: block; + padding: 0; + padding: 1.25rem; + margin-bottom: 20px; + margin-bottom: 1.25rem; + overflow: auto; + color: #000; +} + +pre code { + padding: 0; + color: inherit; + white-space: inherit; + background: inherit; + border: 0; +} + +kbd { + padding: 2px 3px; + color: #fff; + background-color: #2a2a2a; +} + +blockquote { + display: block; + padding: 5px 0 5px 15px; + margin: 0 0 20px; + margin: 0 0 1.25rem; + line-height: 1.6; + border-left: 5px solid {{ $highlightColor }}; +} + +blockquote p:last-child { + margin: 0; +} + +blockquote footer { + text-align: right; +} + +sup, +sub { + font-size: 10px; + font-size: .625rem; + font-style: normal; +} + +sup { + vertical-align: super; +} + +sub { + vertical-align: sub; +} + +abbr[title] { + text-decoration: none; + cursor: help; + border-bottom: 1px dotted #000; +} + +q { + font-style: italic; +} + +address { + margin-bottom: 20px; + margin-bottom: 1.25rem; + font-family: "Consolas", Courier New, Courier, monospace; + line-height: 1.5; +} + +dl { + margin: 0 0 10px 20px; +} + +dt, +dd { + display: list-item; +} + +dt { + font-weight: bold; + list-style-type: square; +} + +dd { + margin-left: 20px; + list-style-type: circle; +} + +select { + max-width: 100%; +} + +.warning { + padding: 20px 10px; + text-align: center; + border: 1px solid #ddd; +} + +.warning__icon { + margin-bottom: 20px; + fill: #ddd; +} + +/* Header */ +.header { + background: #fff; +} + +.logo { + padding: 25px; +} + +.logo__link { + display: inline-block; +} + +.logo__item { + display: inline-block; + vertical-align: middle; +} + +.logo__img { + max-height: 256px; +} + +.logo__text { + text-transform: uppercase; +} + +.logo--mixed .logo__item { + margin: .5rem auto; +} + +.logo--mixed .logo__img { + max-width: 128px; + max-height: 128px; +} + +.logo--mixed .logo__text { + padding: 0 1rem; +} + +.logo__title { + font-size: 32px; + font-size: 2rem; + font-weight: 700; + line-height: 1; + color: #000; +} + +.logo__tagline { + display: inline-block; + padding-top: 10px; + margin-top: 10px; + font-size: 14px; + font-size: .875rem; + font-weight: 700; + line-height: 1; + color: {{ $highlightColor }}; + border-top: 1px solid #ebebeb; +} + +.divider { + height: 5px; + margin: 0; + background: {{ $highlightColor }}; + border: 0; +} + +/* Main menu */ +.no-js .menu__btn { + display: none; +} + +.menu__btn { + display: block; + width: 100%; + padding: 0; + font: inherit; + color: #fff; + background: #2a2a2a; + border: 0; + outline: 0; +} + +.menu__btn-title { + position: relative; + display: block; + padding: 10px 15px; + padding: .625rem .9375rem; + font-weight: 700; + text-align: right; + text-transform: uppercase; + cursor: pointer; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + -o-user-select: none; + user-select: none; +} + +:focus > .menu__btn-title { + box-shadow: inset 0 0 1px 3px {{ $highlightColor }}; +} + +button:not(:-moz-focusring):focus > .menu__btn-title { + box-shadow: none; +} + +.menu__btn:focus, +.menu__btn-title:focus { + outline: 0; +} + +.js .menu__btn--active { + color: {{ $highlightColor }}; +} + +.menu__list { + list-style: none; + background: #2a2a2a; +} + +.menu__item:hover { + background: {{ $highlightColor }}; +} + +.menu__item:first-child { + border: 0; +} + +.menu__item--active { + background: {{ $highlightColor }}; +} + +.menu__link { + display: block; + padding: 10px 15px; + padding: .625rem .9375rem; + font-weight: 700; + color: #fff; + text-transform: uppercase; +} + +.menu__link:hover { + color: #fff; +} + +.js .menu__list { + position: absolute; + z-index: 1; + width: 100%; + visibility: hidden; + -webkit-transform: scaleY(0); + transform: scaleY(0); + -webkit-transform-origin: top left; + transform-origin: top left; +} + +.js .menu__list--active { + visibility: visible; + border-top: 1px solid rgba(255, 255, 255, .1); + border-bottom: 1px solid rgba(255, 255, 255, .1); + -webkit-transform: scaleY(1); + transform: scaleY(1); +} + +.menu__list--transition { + transition: visibility .15s ease, transform .15s ease, -webkit-transform .15s ease; +} + +@media screen and (min-width: 767px) { + .menu { + border-bottom: 5px solid {{ $highlightColor }}; + } + + .menu__btn { + display: none; + } + + .menu__list, + .js .menu__list { + position: relative; + display: -webkit-flex; + display: flex; + -webkit-flex-wrap: wrap; + flex-wrap: wrap; + visibility: visible; + border: 0; + -webkit-transform: none; + transform: none; + } + + .menu__item { + border-left: 1px solid rgba(255, 255, 255, .1); + } +} + +/* Posts/Pages */ +.post__header, +.main__header { + margin-bottom: 20px; + margin-bottom: 1.25rem; +} + +.main__title { + font-size: 28px; + font-size: 1.75rem; +} + +.main__content { + margin-bottom: 20px; + margin-bottom: 1.25rem; +} + +.meta { + font-size: 13px; + font-size: .8125rem; + vertical-align: baseline; +} + +.meta, +.meta a { + color: #666; +} + +.meta a:hover { + color: {{ $highlightColor }}; +} + +.meta__item { + display: inline; + margin-left: 15px; +} + +.meta__item:first-child { + margin-left: 0; +} + +.meta__icon { + margin-right: 5px; + vertical-align: middle; + fill: #c4c4c4; +} + +.meta__text { + vertical-align: middle; +} + +.post__title { + margin: 0; +} + +.post__meta { + padding: 5px 0; + margin-top: 10px; + margin-top: .625rem; + border-top: 1px dotted #ebebeb; + border-bottom: 1px dotted #ebebeb; +} + +.post__lead { + margin-top: 4px; + margin-top: .25rem; + margin-bottom: 0; + font-size: 16px; + font-size: 1rem; + font-style: italic; +} + +.post__thumbnail { + max-width: 1030px; + margin: 0 0 20px; + margin-bottom: 0 0 1.25rem; +} + +.post__thumbnail img { + width: 100%; +} + +.content a, +.warning a, +.authorbox__description a { + font-weight: 700; + color: {{ $highlightColor }}; +} + +.content a:hover, +.warning a:hover, +.authorbox__description a:hover { + color: {{ $highlightColor }}; + text-decoration: underline; +} + +.content .alignnone { + display: block; + margin: 20px 0; + margin: 1.25rem 0; +} + +.content .aligncenter { + display: block; + margin: 20px auto; + margin: 1.25rem auto; +} + +.content .alignleft { + display: inline; + float: left; + margin: 5px 20px 20px 0; + margin: .3125rem 1.25rem 1.25rem 0; +} + +.content .alignright { + display: inline; + float: right; + margin: 5px 0 20px 20px; + margin: .3125rem 0 1.25rem 1.25rem; +} + +.content ul { + list-style: square; +} + +.content ol { + list-style: decimal; +} + +.content ul, +.content ol { + margin: 0 0 20px 40px; +} + +.content ul ul, +.content ol ol, +.content ol ul, +.content ul ol { + margin: 0 0 0 40px; +} + +.content li { + margin-bottom: 5px; +} + +.post__footer { + margin-top: 20px; + margin-top: 1.25rem; +} + +/* Post tags */ +.tags { + margin-bottom: 20px; + margin-bottom: 1.25rem; + font-size: 12px; + font-size: .75rem; + line-height: 1; + color: #fff; +} + +.tags__list { + list-style: none; +} + +.tags__item { + float: left; + margin: 0 6px 6px 0; + margin: 0 .375rem .375rem 0; + text-transform: uppercase; + background: #2a2a2a; +} + +.tags__item:hover { + background: {{ $highlightColor }}; +} + +.tags__link, +.tags__link:hover { + display: block; + padding: 10px 15px; +} + +.tags__badge { + float: left; + width: 32px; + height: 32px; + padding: 8px; + margin-right: 6px; + background: {{ $highlightColor }}; + fill: #fff; +} + +/* Table of Contents */ +.toc { + margin-bottom: 20px; + font-weight: 700; + color: #7a8288; + background: #fff; + border-color: #ebebeb; + border-style: solid; + border-top-width: 1px; + border-right-width: 1px; + border-bottom-width: 0; + border-left-width: 1px; +} + +.toc__title { + padding: 5px 10px; + color: #fff; + text-transform: uppercase; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + -o-user-select: none; + user-select: none; + background: #2a2a2a; +} + +.toc__menu ul { + margin: 0; + list-style: none; +} + +.toc__menu li li a { + padding-left: 25px; +} + +.toc__menu li li li a { + padding-left: 45px; +} + +.toc__menu li li li li a { + padding-left: 65px; +} + +.toc__menu li li li li li a { + padding-left: 85px; +} + +.toc__menu li li li li li li a { + padding-left: 105px; +} + +.toc__menu li { + margin: 0; +} + +.toc__menu a { + display: block; + padding: 5px 10px; + color: {{ $highlightColor }}; + border-bottom: 1px solid #ebebeb; +} + +.toc__menu a:hover { + text-decoration: underline; +} + +/* Author Box */ +.authorbox { + padding: 25px 0; + margin-bottom: 25px; + line-height: 1.5; + border-top: 1px solid #ebebeb; + border-bottom: 1px solid #ebebeb; +} + +.authorbox__avatar { + float: left; + padding: 3px; + margin: 0 25px 0 0; + border: 1px solid #ebebeb; +} + +.authorbox__header { + margin-bottom: 10px; +} + +.authorbox__name { + font-size: 16px; + font-size: 1rem; + font-weight: 700; +} + +/* List content */ +.list__item { + padding-bottom: 20px; + padding-bottom: 1.25rem; + margin-bottom: 20px; + margin-bottom: 1.25rem; + border-bottom: 1px solid #ebebeb; +} + +.list__header { + margin-bottom: 10px; + margin-bottom: .625rem; +} + +.list__title { + font-size: 20px; + font-size: 1.25rem; +} + +.list__meta { + margin-top: 5px; +} + +.list__thumbnail { + float: left; + margin: 0 20px 0 0; +} + +.list__thumbnail img { + width: 100%; + max-width: 235px; +} + +.list__footer-readmore { + float: right; + margin-top: 10px; +} + +/* Pagination */ +.pagination { + margin-top: 20px; +} + +.pagination__item { + display: inline-block; + padding: 10px 15px; + font-weight: 700; + color: #000; + background: #f5f5f5; +} + +.pagination__item:hover, +.pagination__item--current { + color: #fff; + background: {{ $highlightColor }}; +} + +/* Pager (prev/next links) navigation */ +.pager { + -webkit-justify-content: space-between; + justify-content: space-between; + padding-top: 25px; + padding-bottom: 25px; + margin-bottom: 25px; + border-bottom: 1px solid #ebebeb; +} + +.pager__subtitle { + display: block; + margin-bottom: 5px; + font-weight: 700; + line-height: 1; + text-transform: uppercase; +} + +.pager__title { + margin-bottom: 0; + overflow: hidden; + font-size: 13px; + font-size: .8125rem; +} + +.pager__item { + -webkit-flex: 1 1 50%; + flex: 1 1 50%; + max-width: 48%; +} + +.pager__item--next { + margin-left: auto; + text-align: right; +} + +.pager__link { + display: block; +} + +/* Images / Video */ +img { + width: auto\9; /* ie8 */ + max-width: 100%; + height: auto; + vertical-align: bottom; +} + +iframe, +embed, +object, +video { + max-width: 100%; +} + +/* Table */ +table { + width: 100%; + margin-bottom: 20px; + margin-bottom: 1.25rem; + border-spacing: 0; + border-collapse: collapse; + border-top: 1px solid #ebebeb; + border-left: 1px solid #ebebeb; +} + +td, +th { + padding: 5px 10px; + border-right: 1px solid #ebebeb; + border-bottom: 1px solid #ebebeb; +} + +th { + font-weight: 700; +} + +/* Forms */ +input { + padding: 5px; + font-size: 12px; + vertical-align: middle; + background: #f5f5f5; + border: 1px solid #ebebeb; + transition: all .25s ease-in-out; +} + +input[type=text], +input[type=email], +input[type=tel], +input[type=url] { + width: 60%; +} + +input[type=text]:hover, +input[type=email]:hover, +input[type=tel]:hover, +input[type=url]:hover, +textarea:hover { + border: 1px solid #aaa; +} + +input[type=submit], +input[type=reset] { + display: inline-block; + min-width: 150px; + padding: 10px 15px; + font-weight: 700; + color: #fff; + text-transform: uppercase; + cursor: pointer; + background: #2a2a2a; + border: 0; + transition: all .1s linear; + -webkit-appearance: none; +} + +input[type=submit]:hover, +input[type=reset]:hover { + background: {{ $highlightColor }}; +} + +textarea { + width: 96%; + padding: 5px; + overflow: auto; + line-height: 1.5; + resize: vertical; + background: #f5f5f5; + border: 1px solid rgba(0, 0, 0, .1); +} + +/* Widgets */ +.widget { + margin-bottom: 25px; + overflow: hidden; +} + +.widget:last-child { + margin-bottom: 0; +} + +.widget__title { + position: relative; + padding-bottom: 5px; + font-size: 16px; + font-size: 1rem; + text-transform: uppercase; + border-bottom: 3px solid {{ $highlightColor }}; +} + +.widget__item { + display: block; + padding: 5px 0; + border-bottom: 1px dotted #ebebeb; +} + +.widget__item:first-child { + padding-top: 0; +} + +.widget__counter--bubble { + display: inline-block; + padding: 0 6px; + font-size: .75rem; + color: #666; + text-align: center; + background: #ebebeb; + border-radius: 2em; +} + +/* Search widget */ +.widget-search__form { + display: block; + padding: 5%; + margin: 0 auto; + background: #f5f5f5; +} + +.widget-search__form .widget-search__submit { + display: none; +} + +.widget-search__field { + position: relative; + display: block; + width: 90%; + padding: 8px; + margin: 0 auto; + font-size: 11px; + cursor: pointer; + background: #fff; + border: 1px solid #ebebeb; + border-radius: 0; + outline-offset: -2px; + transition: none; + -webkit-appearance: none; +} + +.widget-search__field:active, +.widget-search__field:focus { + cursor: text; +} + +/* Social widget */ +.widget-social__item { + padding: 0; + border: 0; +} + +.widget-social__link { + display: block; + margin: 0 0 8px; + white-space: normal; +} + +.widget-social__link-icon { + margin: 0 5px 0 0; + vertical-align: middle; + fill: #fff; +} + +/* Tags Widget */ +.widget-taglist__link { + display: inline-block; + margin: 0 4px 8px 0; + font-size: 12px; + text-transform: uppercase; +} + +/* Languages Widget */ +.widget-languages__link { + display: block; +} + +.widget-languages__link:hover .widget-languages__link-btn { + color: #fff; + background: {{ $highlightColor }}; +} + +.widget-languages__link-btn { + display: inline-block; +} + +/* Footer */ +.footer { + padding: 10px 25px; + font-size: 12px; + font-size: .75rem; + color: #999; + background: #2a2a2a; + border-top: 3px solid #999; +} + +.footer__container { + -webkit-flex-flow: row wrap; + flex-flow: row wrap; + -webkit-justify-content: space-between; + justify-content: space-between; +} + +.footer__links { + -webkit-order: 1; + order: 1; +} + +.footer a { + color: #fff; +} + +.footer a:hover { + text-decoration: underline; +} + +/* Media Queries */ +@media screen and (max-width: 1475px) { + .container--outer { + width: 95%; + } +} + +@media screen and (max-width: 900px) { + .container--outer { + width: 100%; + margin: 0 auto; + } + + .wrapper, + .logo { + padding: 20px; + } + + .widget { + margin-bottom: 20px; + } + + .footer__container { + display: block; + } + + .footer__links { + padding-bottom: 8px; + padding-bottom: 0.5rem; + text-align: center; + } + + .footer__copyright { + text-align: center; + } +} + +@media screen and (max-width: 767px) { + .wrapper { + display: block; + } + + .sidebar { + float: none; + width: 100%; + margin: 0; + } + + .logo { + text-align: center; + } + + .logo__link { + margin: 0 auto; + } + + .logo__title { + font-size: 24px; + font-size: 1.5rem; + } + + .sidebar { + margin-top: 20px; + } +} + +@media screen and (max-width: 620px) { + input[type=text], + input[type=email], + input[type=tel], + input[type=url] { + width: 88%; + } + + .meta__item { + display: block; + margin-left: 0; + } + + .authorbox { + text-align: center; + } + + .authorbox__avatar { + display: inline-block; + float: none; + margin: 0 0 20px; + } + + .pager { + display: block; + } + + .pager__item { + min-width: 100%; + text-align: center; + } + + .pager__item--prev { + padding-bottom: 25px; + } + + .content ul, + .content ol { + margin: 0 0 20px 20px; + } + + .content ul ul, + .content ol ol, + .content ol ul, + .content ul ol { + margin: 0 0 0 20px; + } + + .list__thumbnail { + max-width: 80px; + } + + .list__title { + font-size: 16px; + font-size: 1rem; + } + + .list__lead { + font-size: 14px; + font-size: .875rem; + } + + .list__meta { + display: block; + font-size: 11px; + font-size: .6875rem; + } +} diff --git a/themes/Gregroad/exampleSite/.gitignore b/themes/Gregroad/exampleSite/.gitignore new file mode 100644 index 0000000..364c4c9 --- /dev/null +++ b/themes/Gregroad/exampleSite/.gitignore @@ -0,0 +1,2 @@ +public/ +themes diff --git a/themes/Gregroad/exampleSite/config.toml b/themes/Gregroad/exampleSite/config.toml new file mode 100644 index 0000000..221797a --- /dev/null +++ b/themes/Gregroad/exampleSite/config.toml @@ -0,0 +1,36 @@ +baseurl = "/" +title = "Mainroad" +languageCode = "en-us" +paginate = "10" # Number of posts per page +theme = "mainroad" +disqusShortname = "" # Enable comments by entering your Disqus shortname +googleAnalytics = "" # Enable Google Analytics by entering your tracking id + +[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] + description = "John Doe's Personal blog about everything" # Description of your site + opengraph = true + twitter_cards = false + readmore = false # Show "Read more" button in list if true + authorbox = true + pager = true + post_meta = ["date", "categories"] # Order of post meta information + mainSections = ["post", "docs"] + +[Params.logo] + subtitle = "Just another site" # Logo subtitle + +[Params.sidebar] + home = "right" # Configure layout for home page + list = "right" # Configure layout for list pages + single = "right" # Configure layout for single pages + # Enable widgets in given order + widgets = ["search", "recent", "categories", "taglist"] + +[Params.widgets] + recent_num = 5 # Set the number of articles in the "Recent articles" widget + tags_counter = false # Enable counter for each tag in "Tags" widget (disabled by default) diff --git a/themes/Gregroad/exampleSite/content/about.md b/themes/Gregroad/exampleSite/content/about.md new file mode 100644 index 0000000..e9f9f78 --- /dev/null +++ b/themes/Gregroad/exampleSite/content/about.md @@ -0,0 +1,41 @@ +--- +title: About +date: 2022-01-25T14:00:00.000Z +authorbox: false +sidebar: false +menu: main +--- + +Our website builds with [Hugo](https://gohugo.io/) static site generator and +[Mainroad](https://github.com/vimux/mainroad) theme. This demo allows you to see what Mainroad based website looks like +before deciding to go with it. Just keep in mind that the current demo shows the basics, a small part of what the +combination of Hugo and Mainroad can do. + +## About Mainroad + +Mainroad is a responsive, simple, clean and content-focused Hugo theme based on the MH Magazine lite WordPress theme. + +Main features: + +* Responsive design +* Main & secondary menus +* Widgetized sidebar +* Translations. Over 15 languages and counting +* Configurable theme settings (sidebar position, author box, post navigation, highlight color) via config.toml +* Hugo internal templates (Open Graph, Schema, Twitter Cards, Disqus, Google Analytics) +* Wide cross-browser compatibility + * Desktop: IE11+, Chrome, Firefox, Safari + * Mobile: Android browser (on Android 4.4+), Safari (on iOS 7+), Google Chrome, Opera mini +* Custom Google Fonts support, MathJax, Table of Contents, SVG icons and much more… + +Learn more on [GitHub](https://github.com/vimux/mainroad). Mainroad theme is released under the +[GPLv2 license](https://github.com/vimux/mainroad/blob/master/LICENSE.md). + +## About Hugo + +Hugo is a static HTML and CSS website generator written in Go. It is optimized for speed, ease of use, and +configurability. Hugo takes a directory with content and templates and renders them into a full HTML website. With its +amazing speed and flexibility, Hugo makes building websites fun again. + +Learn more on [GitHub](https://github.com/gohugoio/hugo). Complete documentation is available at +[Hugo Documentation](https://gohugo.io/getting-started/). diff --git a/themes/Gregroad/exampleSite/content/docs/_index.md b/themes/Gregroad/exampleSite/content/docs/_index.md new file mode 100644 index 0000000..0ac66aa --- /dev/null +++ b/themes/Gregroad/exampleSite/content/docs/_index.md @@ -0,0 +1,4 @@ +--- +title: Documentation +description: Mainroad theme documentation, including getting started, customization guides, and FAQ. +--- diff --git a/themes/Gregroad/exampleSite/content/docs/customization.md b/themes/Gregroad/exampleSite/content/docs/customization.md new file mode 100644 index 0000000..0b4a664 --- /dev/null +++ b/themes/Gregroad/exampleSite/content/docs/customization.md @@ -0,0 +1,269 @@ +--- +title: Customization +description: Describes common Mainroad theme configuration parameters that can be adjusted via config file or via Front + Matter section. +lead: Describes common Mainroad theme configuration parameters that can be adjusted via config file or via Front Matter + section. +date: 2022-01-24T14:00:00.000Z +thumbnail: + src: "img/placeholder.png" + visibility: + - list +authorbox: false +sidebar: false +pager: false +weight: 2 +menu: main +--- + +Customization page describes common Mainroad configuration parameters which can be specified via configuration file or +via Front Matter section. That includes logo section tuning, adding a sidebar with widgets, adjusting highlight color, +and more. + + + +This section will mainly cover customization settings that are unique to this theme. If something is not covered here, +there's a good chance it is covered somewhere in [Hugo docs](https://gohugo.io/documentation/). + +### Logo + +**Mainroad** allows you to set a custom logo in the site header. You may use text, or image, or both. Use the following +options in your site config: + +```toml +[Params.logo] + image = "img/placeholder.png" + title = "Mainroad" + subtitle = "Just another site" +``` + +**Note:** logo image will display at a maximum width of 128 pixels and a maximum height of 128 pixels +when you use text and image simultaneously. When the only logo image is active, it will display at a maximum height of +256 pixels. Ideally, your logo image should be SVG. + +--- + +If you don't set any of these variables, the theme uses the site title as a logo title. Don't need a logo section? +Disable it this way: + +```toml +[Params.logo] + image = false + title = false + subtitle = false +``` + +### Highlight color + +Mainroad uses `#e22d30` as a default highlight color, but you may choose and set any other color. + +```toml +[Params.style.vars] + highlightColor = "#e22d30" +``` + +### Thumbnail visibility + +By default, a thumbnail image has shown for a list and single pages simultaneously. In some cases, you may want to show +a thumbnail for list-like pages only and hide it on single pages (or vice versa). Control global thumbnail visibility +via config, use the key `visibility` with combination of valid values `"list"` and `"post"`. + +```toml +[Params.thumbnail] + # Show thumbnail only for list items + visibility = ["list"] +``` + +Besides global configuration, you can change thumbnail visibility individually with extended thumbnail notation via +front matter block. + +```yaml +thumbnail: + src: "img/placeholder.png" + visibility: + - list + - post +``` + +This page is an example of list-only thumbnail visibility. + +### Sidebar + +**Mainroad** comes with a configurable sidebar that can be on the left, on the right, or disabled. The default layout +can be specified in the `[Params.sidebar]` section of the configuration. The position can be specified for home, list +and single pages individually. Use the keys `home`, `list` and `single` with values `"left"`, `"right"` or `false`. + +```toml +[Params.sidebar] + home = "right" + list = "right" + single = "right" +``` + +The layout can be configured per page, by setting the `sidebar` parameter with one of the same values (`"left"`, +`"right"` or `false`) in the page's front matter. + +```yaml +sidebar: "left" # Enable sidebar (on the left side) per page +``` + +The sidebar consists of multiple widgets. Widgets can be enabled individually using the `widgets` key with a list of +widget names as value. You can add your own widgets, by placing a template under `layouts/partials/widgets/.html`. + +```toml +[Params.sidebar] + # Enable widgets in given order + widgets = ["search", "recent", "categories", "taglist", "social", "languages"] +``` + +The list of widgets can be overwritten from a page's front matter. + +```yaml +# Enable sidebar widgets in given order +widgets: + - "search" + - "recent" + - "taglist" +``` + +Full list of available default widgets: + +* `search`, `ddg-search`, `recent`, `categories`, `taglist`, `social`, `languages` + +--- + +Some of our widgets respect optional configuration. Have a look at the `[Params.widgets]` and `[Params.widgets.social]` +sections in the example below. + +```toml +[Params.widgets] + recent_num = 5 # Set the number of articles in the "Recent articles" widget + categories_counter = false # Enable counter for each category in "Categories" widget + tags_counter = false # Enable counter for each tag in "Tags" widget +``` + +```toml +[Params.widgets.social] + # Enable parts of social widget + facebook = "username" + twitter = "username" + instagram = "username" + linkedin = "username" + telegram = "username" + github = "username" + gitlab = "username" + bitbucket = "username" + email = "example@example.com" +``` + +### Social Widget: custom links + +**Mainroad** contains built-in social links in the social widget. In addition to default social links, you may set +custom links by adding `Params.widgets.social.custom` to your `config.toml`. Here is an example: + +```toml +[[Params.widgets.social.custom]] + title = "My Home Page" + url = "https://example.com" +``` + +If you want to display an icon of your social link, you need to put SVG icon file in `layouts/partials` directory under +your site's root. The `icon` key filed, which is optional, should be a path relative to `layouts/partials`. + +```toml +[[Params.widgets.social.custom]] + title = "Youtube" + url = "https://youtube.com/user/username" + icon = "youtube.svg" +``` + +**Note:** *Only* SVG files are supported to be used as custom social icons. If you use any other files, PNG for example, +a compile error will be raised by Hugo. Moreover, not every SVG icon can be used. For better results, it should be +one-color SVG file with a special class attribute `{{ with .class }}{{ . }} {{ end }}` and 24x24 size. At a minimum, +custom SVG icon needs these attributes: + +```html +... +``` + +### Menus + +**Mainroad** supports multiple menus. The `main` menu is fully responsive and displayed right under the site header. The +secondary menus `side` and `footer` are displayed in a sidebar widget and the page footer respectively. To add a page to +a menu, add a `menu: ` parameter to the page's front matter: + +```yaml +menu: main # Add page to a main menu +``` + +**Note:** Don't forget to enable the `sidemenu` widget in the `widgets` configuration param if you want to use the +`side` menu. + +--- + +You can also add a page to multiple menus by providing a list: + +```yaml +# Add page to a main, side, and footer menu +menu: + - main + - side + - footer +``` + +**Note:** Please keep in mind that Mainroad menus don't support nested items i.e. submenus. + +See [Menus](https://gohugo.io/content-management/menus/#readout) from official Hugo documentation for more info. + +### Custom Google Fonts support + +Mainroad uses Open Sans from Google Fonts as a main font. But you can use any other font from Google Fonts if you'd +like. Beware, in most cases, such changes require manual CSS adjustment because every set of fonts is different and +might not look as good as our default font. + +Follow the procedure below. + +1. Open Google Fonts, choose font(s) that you prefer and copy href font link. For this particular example, we choose +[Roboto with 3 different styles](https://fonts.google.com/share?selection.family=Roboto:ital,wght@0,400;0,700;1,400;1,700). +Our href font link: + + ``` + https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,700;1,400&display=swap + ``` + +1. Set `googleFontsLink` site's config param value to your href font link. For example: + + ```toml + [Params] + googleFontsLink = "https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,700;1,400&display=swap" + ``` + +1. Override default font-family set(s): + + ```toml + [Params.style.vars] + fontFamilyPrimary = "'Roboto', sans-serif" + ``` + +--- + +It is possible to disable Google Fonts and use system font stack instead. + +1. Disable Google Fonts include. Set `googleFontsLink` site's config param value to `false`: + + ```toml + [Params] + googleFontsLink = false + ``` + +1. Override font-family sets: + + ```toml + [Params.style.vars] + # Override font-family sets. Take care of different quotes OR escaping symbols in these params if necessary + fontFamilyPrimary = "system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'Liberation Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'" + # Secondary font-family set responsible for pre, code, kbd, and samp tags font + fontFamilySecondary = "SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace" + ``` + +[Edit this page on GitHub](https://github.com/vimux/mainroad/blob/master/exampleSite/content/docs/customization.md) diff --git a/themes/Gregroad/exampleSite/content/docs/faq.md b/themes/Gregroad/exampleSite/content/docs/faq.md new file mode 100644 index 0000000..f982e9f --- /dev/null +++ b/themes/Gregroad/exampleSite/content/docs/faq.md @@ -0,0 +1,85 @@ +--- +title: Frequently asked questions (FAQ) +description: Browse this FAQ page to find answers to frequently asked questions that have not been covered elsewhere in + the documentation. +date: 2022-01-24T14:00:00.000Z +authorbox: false +sidebar: false +pager: false +weight: 3 +menu: + main: + name: FAQ +--- + +Browse this FAQ page to find a collection of answers to frequently asked questions that have not been covered elsewhere +in the documentation. + + + +The answers have been categorized into two groups. Those are answers to general questions without any lines of code, and +those are answers to technical questions with code snippets, step-by-step instructions, etc. + +## General questions + +### Do I need to have some prior experience before proceed with Mainroad theme? + +**Yes.** We expect that you already have prior experience with Hugo, at least. +[Our docs section]({{< ref "/docs/_index.md" >}} "Mainroad theme documentation") is for intermediate users and +developers, not novice users with zero or minimal experience. Still, all documentation pages would be helpful even if +you don't have such experience. Just don't expect all your typical questions answered here. + +### Do I need to use the extended version of Hugo? + +**No.** Mainroad theme intentionally does not use any features of the extended version. As such, the extended version of +Hugo is not required (but applicable). + +### Is there a list of all possible configuration options? + +**Configuration:** + +* See [All Configuration Settings](https://gohugo.io/getting-started/configuration/#all-configuration-settings) section +for the full list of Hugo-defined variables with their default value. +* See [Mainroad config.toml example](https://github.com/Vimux/Mainroad#configtoml-example) for the full list of +Mainroad-specific variables. + +**Front Matter:** + +* See [Front Matter Variables](https://gohugo.io/content-management/front-matter#front-matter-variables) section for the +list of Hugo-defined Front Matter variables. +* See [Mainroad Front Matter example](https://github.com/Vimux/Mainroad#front-matter-example) section for the list of +Mainroad-specific Front Matter variables. + +### What if I have more questions? May I should create an issue? + +**We don't provide free personal technical support.** As stated in +[CONTRIBUTING](https://github.com/Vimux/Mainroad/blob/master/CONTRIBUTING.md), please do not use the issue tracker for +personal support. This includes any reports like “how to do this or that”; “everything broken, help me”; “I changed +something, it doesn't work anymore”; “It's not a personal issue, I just want to ask how X or Y works”; “I forked your +theme, then something broken, fix this immediately” and so on. **The issue tracker is the preferred channel for bug +reports, feature requests, and discussions that comply with our contributing rules**, nothing more. All other issues +would be closed and marked as invalid. + +## Technical questions + +**I wanted to get the `favicon.ico` and `apple-touch-icon.png` to match my `hightlightColor`, what should I do?** + +There is no way to do this on the fly with Hugo, but you may use two one-liners below with some preparations: + +1. Copy: + * `./themes/mainroad/favicon.ico` to `./static/favicon.ico` + * `./themes/mainroad/apple-touch-icon.png` to `./static/apple-touch-icon.png` +1. Replace the color in variable to your preferred at the beginning of both scripts. Beware, you should use full +six-digit Hex triplet notation (e.g., `#E22D30`) to make it work properly. + +Go to the root of your project directory in the terminal and execute this two commands accordingly. + +``` +a=#E22D30;a=\\x${a:5:2}\\x${a:3:2}\\x${a:1:2};for i in 98 274 578;do printf $a|dd of=static/favicon.ico bs=1 seek=$i conv=notrunc;done +``` + +``` +a=#E22D30;a=$(echo 504C54452A2A2A${a:1:6}|sed -e 's/../\\x&/g');printf $a|gzip|tail -c8|od -tx4 -N4 -An|xargs|sed -e 's/../\\x&/g'|printf $a$(cat -)|dd of=static/apple-touch-icon.png bs=1 seek=37 conv=notrunc +``` + +[Edit this page on GitHub](https://github.com/vimux/mainroad/blob/master/exampleSite/content/docs/faq.md) diff --git a/themes/Gregroad/exampleSite/content/docs/getting-started.md b/themes/Gregroad/exampleSite/content/docs/getting-started.md new file mode 100644 index 0000000..93c2c94 --- /dev/null +++ b/themes/Gregroad/exampleSite/content/docs/getting-started.md @@ -0,0 +1,89 @@ +--- +title: Getting started +description: This article helps you get started with the Mainroad theme, including installation and minimal + configuration. +lead: This article helps you get started with the Mainroad theme, including installation and minimal configuration. +date: 2022-01-24T14:00:00.000Z +tags: + - "Installation" +authorbox: false +sidebar: false +pager: false +weight: 1 +menu: main +--- + +Welcome to the Mainroad theme documentation. This quick guide has been written for intermediate and advanced users who +are interested in getting started with the Mainroad theme, including installation and minimal configuration. To fully +understand the rest of this guide, you need to be familiar with the main concepts of the [Hugo](https://gohugo.io/) +static site generator. + + + +## Installation + +To begin with **Mainroad** theme, you should have +[**Hugo** (version 0.48 or later) installed](https://gohugo.io/getting-started/quick-start/#step-1-install-hugo) and +[create a new site](https://gohugo.io/getting-started/quick-start/#step-2-create-a-new-site). For comprehensive Hugo +installation guide, please visit [Hugo Documentation](https://gohugo.io/getting-started/installing/). After that, you +are ready to install Mainroad theme. + +There are a few options to install a theme in Hugo. This can be done via git submodule, git clone, Hugo modules, or even +by downloading the archive and manually copying the files. Use what you know and what works best for you. Three +installation options are described below. + +### Option A: `git submodule` + +*Additional requirements: git* + +If you don't plan to make any significant changes but want to track and update the theme, you can add it as a [git +submodule](https://git-scm.com/docs/git-submodule) by running the following command from the root directory of your Hugo +site: + +```sh +git submodule add https://github.com/vimux/mainroad.git themes/mainroad +``` + +**Note:** +[Netlify expects git submodule](https://docs.netlify.com/configure-builds/common-configurations/hugo/#hugo-themes) +instead of git clone. + +### Option B: `git clone` + +*Additional requirements: git* + +Run this [git clone](https://git-scm.com/docs/git-clone) command from the root of your Hugo site: + +```sh +git clone https://github.com/vimux/mainroad.git themes/mainroad +``` + +### Option C: Manual install + +If you do not want to use git for some reason, you can manually +**[download ZIP](https://github.com/vimux/mainroad/archive/master.zip)** and extract it into the `themes/mainroad` +within your Hugo site. + +--- + +### Activate theme + +No matter what option do you choose above, don't forget to edit `theme` param of the site configuration `config.toml`: + +```toml +theme = "mainroad" +``` + +Done. Build the site via `hugo` command or make it available on a local server via `hugo server` to check it out. + +## Minimal configuration + +**We don't recommend copying [example config](https://github.com/vimux/mainroad#configtoml-example) as-is.** +Mainroad theme contains required defaults, so you don't need to add all of configuration parameters to run the +theme for the first time without errors from Hugo. Make sure that you edit the `theme` param inside the config file +and check that theme works. Only then start to add theme-specific parameters that you really need. +[Customization page]({{< relref "/docs/customization.md" >}} "Mainroad theme customization") describes common settings +that you may want to change and our [demo config](https://github.com/vimux/mainroad/blob/master/exampleSite/config.toml) +could help with configuration too. + +[Edit this page on GitHub](https://github.com/vimux/mainroad/blob/master/exampleSite/content/docs/getting-started.md) diff --git a/themes/Gregroad/exampleSite/content/post/basic-elements.md b/themes/Gregroad/exampleSite/content/post/basic-elements.md new file mode 100644 index 0000000..02bfdaa --- /dev/null +++ b/themes/Gregroad/exampleSite/content/post/basic-elements.md @@ -0,0 +1,170 @@ +--- +title: Basic HTML Elements +description: Example test article that contains basic HTML elements for text formatting on the Web. +date: 2018-04-16 +categories: + - "Development" +tags: + - "HTML" + - "CSS" + - "Basic Elements" +menu: + main: + name: Basic Elements + weight: 4 +--- + +The main purpose of this article is to make sure that all basic HTML Elements are decorated with CSS so as to not miss any possible elements when creating new themes for Hugo. + + +## Headings + +Let's start with all possible headings. The HTML `

`—`

` elements represent six levels of section headings. `

` is the highest section level and `

` is the lowest. + +# Heading 1 +## Heading 2 +### Heading 3 +#### Heading 4 +##### Heading 5 +###### Heading 6 + +*** + +## Paragraph + +According to the [HTML5 specification](https://www.w3.org/TR/html5/dom.html#elements) by [W3C](https://www.w3.org/), **HTML documents consist of a tree of elements and text**. Each element is denoted in the source by a [start tag](https://www.w3.org/TR/html5/syntax.html#syntax-start-tags), such as ``, and an [end tag](https://www.w3.org/TR/html5/syntax.html#syntax-end-tags), such as ``. (*Certain start tags and end tags can in certain cases be omitted and are implied by other tags.*) + +Elements can have attributes, which control how the elements work. For example, hyperlink are formed using the `a` element and its `href` attribute. + +## List Types + +### Ordered List + +1. First item +2. Second item +3. Third item + +### Unordered List + +* List item +* Another item +* And another item + +### Nested list + +
    +
  • First item
  • +
  • Second item +
      +
    • Second item First subitem
    • +
    • Second item second subitem +
        +
      • Second item Second subitem First sub-subitem
      • +
      • Second item Second subitem Second sub-subitem
      • +
      • Second item Second subitem Third sub-subitem
      • +
      +
    • +
    • Second item Third subitem +
        +
      1. Second item Third subitem First sub-subitem
      2. +
      3. Second item Third subitem Second sub-subitem
      4. +
      5. Second item Third subitem Third sub-subitem
      6. +
      +
    +
  • +
  • Third item
  • +
+ +### Definition List + +HTML also supports definition lists. + +
+
Blanco tequila
+
The purest form of the blue agave spirit...
+
Reposado tequila
+
Typically aged in wooden barrels for between two and eleven months...
+
+ +## Blockquotes + +The blockquote element represents content that is quoted from another source, optionally with a citation which must be within a `footer` or `cite` element, and optionally with in-line changes such as annotations and abbreviations. + +> Quoted text. +> This line is part of the same quote. +> Also you can *put* **Markdown** into a blockquote. + +Blockquote with a citation. + +
+

My goal wasn't to make a ton of money. It was to build good computers. I only started the company when I realized I could be an engineer forever.

+
Steve Wozniak
+
+ +According to Mozilla's website, Firefox 1.0 was released in 2004 and became a big success. + +## Tables + +Tables aren't part of the core Markdown spec, but Hugo supports them. + +| ID | Make | Model | Year | +| --- | --------- | ------- | ---- | +| 1 | Honda | Accord | 2009 | +| 2 | Toyota | Camry | 2012 | +| 3 | Hyundai | Elantra | 2010 | + +Colons can be used to align columns. + +| Tables | Are | Cool | +|:----------- |:-------------:| ------------:| +| align: left | align: center | align: right | +| align: left | align: center | align: right | +| align: left | align: center | align: right | + +You can also use inline Markdown. + +| Inline | Markdown | In | Table | +| ---------- | --------- | ----------------- | ---------- | +| *italics* | **bold** | ~~strikethrough~~ | `code` | + +## Code + +```html + + + + + Example HTML5 Document + + +

Test

+ + +``` + +{{< highlight html >}} + + + + + Example HTML5 Document + + +

Test

+ + +{{< /highlight >}} + +## Other stuff — abbr, sub, sup, kbd, etc. + +GIF is a bitmap image format. + +H2O + +C6H12O6 + +Xn + Yn = Zn + +Press X to win. Or press CTRL+ALT+F to show FPS counter. + +As a unit of information in information theory, the bit has alternatively been called a shannon, named after Claude Shannon, the founder of field of information theory. diff --git a/themes/Gregroad/exampleSite/content/post/creating-a-new-theme.md b/themes/Gregroad/exampleSite/content/post/creating-a-new-theme.md new file mode 100644 index 0000000..a585a76 --- /dev/null +++ b/themes/Gregroad/exampleSite/content/post/creating-a-new-theme.md @@ -0,0 +1,1143 @@ +--- +title: Creating a New Theme +date: 2014-09-28 +author: Michael Henderson +--- + + +## Introduction + +This tutorial will show you how to create a simple theme in Hugo. I assume that you are familiar with HTML, the bash command line, and that you are comfortable using Markdown to format content. I'll explain how Hugo uses templates and how you can organize your templates to create a theme. I won't cover using CSS to style your theme. + +We'll start with creating a new site with a very basic template. Then we'll add in a few pages and posts. With small variations on that, you will be able to create many different types of web sites. + +In this tutorial, commands that you enter will start with the "$" prompt. The output will follow. Lines that start with "#" are comments that I've added to explain a point. When I show updates to a file, the ":wq" on the last line means to save the file. + +Here's an example: + +``` +## this is a comment +$ echo this is a command +this is a command + +## edit the file +$ vi foo.md ++++ +date = "2014-09-28" +title = "creating a new theme" ++++ + +bah and humbug +:wq + +## show it +$ cat foo.md ++++ +date = "2014-09-28" +title = "creating a new theme" ++++ + +bah and humbug +$ +``` + + +## Some Definitions + +There are a few concepts that you need to understand before creating a theme. + +### Skins + +Skins are the files responsible for the look and feel of your site. It’s the CSS that controls colors and fonts, it’s the Javascript that determines actions and reactions. It’s also the rules that Hugo uses to transform your content into the HTML that the site will serve to visitors. + +You have two ways to create a skin. The simplest way is to create it in the ```layouts/``` directory. If you do, then you don’t have to worry about configuring Hugo to recognize it. The first place that Hugo will look for rules and files is in the ```layouts/``` directory so it will always find the skin. + +Your second choice is to create it in a sub-directory of the ```themes/``` directory. If you do, then you must always tell Hugo where to search for the skin. It’s extra work, though, so why bother with it? + +The difference between creating a skin in ```layouts/``` and creating it in ```themes/``` is very subtle. A skin in ```layouts/``` can’t be customized without updating the templates and static files that it is built from. A skin created in ```themes/```, on the other hand, can be and that makes it easier for other people to use it. + +The rest of this tutorial will call a skin created in the ```themes/``` directory a theme. + +Note that you can use this tutorial to create a skin in the ```layouts/``` directory if you wish to. The main difference will be that you won’t need to update the site’s configuration file to use a theme. + +### The Home Page + +The home page, or landing page, is the first page that many visitors to a site see. It is the index.html file in the root directory of the web site. Since Hugo writes files to the public/ directory, our home page is public/index.html. + +### Site Configuration File + +When Hugo runs, it looks for a configuration file that contains settings that override default values for the entire site. The file can use TOML, YAML, or JSON. I prefer to use TOML for my configuration files. If you prefer to use JSON or YAML, you’ll need to translate my examples. You’ll also need to change the name of the file since Hugo uses the extension to determine how to process it. + +Hugo translates Markdown files into HTML. By default, Hugo expects to find Markdown files in your ```content/``` directory and template files in your ```themes/``` directory. It will create HTML files in your ```public/``` directory. You can change this by specifying alternate locations in the configuration file. + +### Content + +Content is stored in text files that contain two sections. The first section is the “front matter,” which is the meta-information on the content. The second section contains Markdown that will be converted to HTML. + +#### Front Matter + +The front matter is information about the content. Like the configuration file, it can be written in TOML, YAML, or JSON. Unlike the configuration file, Hugo doesn’t use the file’s extension to know the format. It looks for markers to signal the type. TOML is surrounded by “`+++`”, YAML by “`---`”, and JSON is enclosed in curly braces. I prefer to use TOML, so you’ll need to translate my examples if you prefer YAML or JSON. + +The information in the front matter is passed into the template before the content is rendered into HTML. + +#### Markdown + +Content is written in Markdown which makes it easier to create the content. Hugo runs the content through a Markdown engine to create the HTML which will be written to the output file. + +### Template Files + +Hugo uses template files to render content into HTML. Template files are a bridge between the content and presentation. Rules in the template define what content is published, where it's published to, and how it will rendered to the HTML file. The template guides the presentation by specifying the style to use. + +There are three types of templates: single, list, and partial. Each type takes a bit of content as input and transforms it based on the commands in the template. + +Hugo uses its knowledge of the content to find the template file used to render the content. If it can’t find a template that is an exact match for the content, it will shift up a level and search from there. It will continue to do so until it finds a matching template or runs out of templates to try. If it can’t find a template, it will use the default template for the site. + +Please note that you can use the front matter to influence Hugo’s choice of templates. + +#### Single Template + +A single template is used to render a single piece of content. For example, an article or post would be a single piece of content and use a single template. + +#### List Template + +A list template renders a group of related content. That could be a summary of recent postings or all articles in a category. List templates can contain multiple groups. + +The homepage template is a special type of list template. Hugo assumes that the home page of your site will act as the portal for the rest of the content in the site. + +#### Partial Template + +A partial template is a template that can be included in other templates. Partial templates must be called using the “partial” template command. They are very handy for rolling up common behavior. For example, your site may have a banner that all pages use. Instead of copying the text of the banner into every single and list template, you could create a partial with the banner in it. That way if you decide to change the banner, you only have to change the partial template. + +## Create a New Site + +Let's use Hugo to create a new web site. I'm a Mac user, so I'll create mine in my home directory, in the Sites folder. If you're using Linux, you might have to create the folder first. + +The "new site" command will create a skeleton of a site. It will give you the basic directory structure and a useable configuration file. + +``` +$ hugo new site ~/Sites/zafta +$ cd ~/Sites/zafta +$ ls -l +total 8 +drwxr-xr-x 7 quoha staff 238 Sep 29 16:49 . +drwxr-xr-x 3 quoha staff 102 Sep 29 16:49 .. +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 archetypes +-rw-r--r-- 1 quoha staff 82 Sep 29 16:49 config.toml +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 content +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 layouts +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 static +$ +``` + +Take a look in the content/ directory to confirm that it is empty. + +The other directories (archetypes/, layouts/, and static/) are used when customizing a theme. That's a topic for a different tutorial, so please ignore them for now. + +### Generate the HTML For the New Site + +Running the `hugo` command with no options will read all the available content and generate the HTML files. It will also copy all static files (that's everything that's not content). Since we have an empty site, it won't do much, but it will do it very quickly. + +``` +$ hugo --verbose +INFO: 2014/09/29 Using config file: config.toml +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ +WARN: 2014/09/29 Unable to locate layout: [index.html _default/list.html _default/single.html] +WARN: 2014/09/29 Unable to locate layout: [404.html] +0 draft content +0 future content +0 pages created +0 tags created +0 categories created +in 2 ms +$ +``` + +The "`--verbose`" flag gives extra information that will be helpful when we build the template. Every line of the output that starts with "INFO:" or "WARN:" is present because we used that flag. The lines that start with "WARN:" are warning messages. We'll go over them later. + +We can verify that the command worked by looking at the directory again. + +``` +$ ls -l +total 8 +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 archetypes +-rw-r--r-- 1 quoha staff 82 Sep 29 16:49 config.toml +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 content +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 layouts +drwxr-xr-x 4 quoha staff 136 Sep 29 17:02 public +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 static +$ +``` + +See that new public/ directory? Hugo placed all generated content there. When you're ready to publish your web site, that's the place to start. For now, though, let's just confirm that we have what we'd expect from a site with no content. + +``` +$ ls -l public +total 16 +-rw-r--r-- 1 quoha staff 416 Sep 29 17:02 index.xml +-rw-r--r-- 1 quoha staff 262 Sep 29 17:02 sitemap.xml +$ +``` + +Hugo created two XML files, which is standard, but there are no HTML files. + + + +### Test the New Site + +Verify that you can run the built-in web server. It will dramatically shorten your development cycle if you do. Start it by running the "server" command. If it is successful, you will see output similar to the following: + +``` +$ hugo server --verbose +INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ +WARN: 2014/09/29 Unable to locate layout: [index.html _default/list.html _default/single.html] +WARN: 2014/09/29 Unable to locate layout: [404.html] +0 draft content +0 future content +0 pages created +0 tags created +0 categories created +in 2 ms +Serving pages from /Users/quoha/Sites/zafta/public +Web Server is available at http://localhost:1313 +Press Ctrl+C to stop +``` + +Connect to the listed URL (it's on the line that starts with "Web Server"). If everything is working correctly, you should get a page that shows the following: + +``` +index.xml +sitemap.xml +``` + +That's a listing of your public/ directory. Hugo didn't create a home page because our site has no content. When there's no index.html file in a directory, the server lists the files in the directory, which is what you should see in your browser. + +Let’s go back and look at those warnings again. + +``` +WARN: 2014/09/29 Unable to locate layout: [index.html _default/list.html _default/single.html] +WARN: 2014/09/29 Unable to locate layout: [404.html] +``` + +That second warning is easier to explain. We haven’t created a template to be used to generate “page not found errors.” The 404 message is a topic for a separate tutorial. + +Now for the first warning. It is for the home page. You can tell because the first layout that it looked for was “index.html.” That’s only used by the home page. + +I like that the verbose flag causes Hugo to list the files that it's searching for. For the home page, they are index.html, _default/list.html, and _default/single.html. There are some rules that we'll cover later that explain the names and paths. For now, just remember that Hugo couldn't find a template for the home page and it told you so. + +At this point, you've got a working installation and site that we can build upon. All that’s left is to add some content and a theme to display it. + +## Create a New Theme + +Hugo doesn't ship with a default theme. There are a few available (I counted a dozen when I first installed Hugo) and Hugo comes with a command to create new themes. + +We're going to create a new theme called "zafta." Since the goal of this tutorial is to show you how to fill out the files to pull in your content, the theme will not contain any CSS. In other words, ugly but functional. + +All themes have opinions on content and layout. For example, Zafta uses "post" over "blog". Strong opinions make for simpler templates but differing opinions make it tougher to use themes. When you build a theme, consider using the terms that other themes do. + + +### Create a Skeleton + +Use the hugo "new" command to create the skeleton of a theme. This creates the directory structure and places empty files for you to fill out. + +``` +$ hugo new theme zafta + +$ ls -l +total 8 +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 archetypes +-rw-r--r-- 1 quoha staff 82 Sep 29 16:49 config.toml +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 content +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 layouts +drwxr-xr-x 4 quoha staff 136 Sep 29 17:02 public +drwxr-xr-x 2 quoha staff 68 Sep 29 16:49 static +drwxr-xr-x 3 quoha staff 102 Sep 29 17:31 themes + +$ find themes -type f | xargs ls -l +-rw-r--r-- 1 quoha staff 1081 Sep 29 17:31 themes/zafta/LICENSE.md +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/archetypes/default.md +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/_default/list.html +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/_default/single.html +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/index.html +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/partials/footer.html +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/partials/header.html +-rw-r--r-- 1 quoha staff 93 Sep 29 17:31 themes/zafta/theme.toml +$ +``` + +The skeleton includes templates (the files ending in .html), license file, a description of your theme (the theme.toml file), and an empty archetype. + +Please take a minute to fill out the theme.toml and LICENSE.md files. They're optional, but if you're going to be distributing your theme, it tells the world who to praise (or blame). It's also nice to declare the license so that people will know how they can use the theme. + +``` +$ vi themes/zafta/theme.toml +author = "michael d henderson" +description = "a minimal working template" +license = "MIT" +name = "zafta" +source_repo = "" +tags = ["tags", "categories"] +:wq + +## also edit themes/zafta/LICENSE.md and change +## the bit that says "YOUR_NAME_HERE" +``` + +Note that the the skeleton's template files are empty. Don't worry, we'll be changing that shortly. + +``` +$ find themes/zafta -name '*.html' | xargs ls -l +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/_default/list.html +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/_default/single.html +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/index.html +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/partials/footer.html +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/partials/header.html +$ +``` + + + +### Update the Configuration File to Use the Theme + +Now that we've got a theme to work with, it's a good idea to add the theme name to the configuration file. This is optional, because you can always add "-t zafta" on all your commands. I like to put it the configuration file because I like shorter command lines. If you don't put it in the configuration file or specify it on the command line, you won't use the template that you're expecting to. + +Edit the file to add the theme, add a title for the site, and specify that all of our content will use the TOML format. + +``` +$ vi config.toml +theme = "zafta" +baseurl = "" +languageCode = "en-us" +title = "zafta - totally refreshing" +MetaDataFormat = "toml" +:wq + +$ +``` + +### Generate the Site + +Now that we have an empty theme, let's generate the site again. + +``` +$ hugo --verbose +INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/ +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ +WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] +0 draft content +0 future content +0 pages created +0 tags created +0 categories created +in 2 ms +$ +``` + +Did you notice that the output is different? The warning message for the home page has disappeared and we have an additional information line saying that Hugo is syncing from the theme's directory. + +Let's check the public/ directory to see what Hugo's created. + +``` +$ ls -l public +total 16 +drwxr-xr-x 2 quoha staff 68 Sep 29 17:56 css +-rw-r--r-- 1 quoha staff 0 Sep 29 17:56 index.html +-rw-r--r-- 1 quoha staff 407 Sep 29 17:56 index.xml +drwxr-xr-x 2 quoha staff 68 Sep 29 17:56 js +-rw-r--r-- 1 quoha staff 243 Sep 29 17:56 sitemap.xml +$ +``` + +Notice four things: + +1. Hugo created a home page. This is the file public/index.html. +2. Hugo created a css/ directory. +3. Hugo created a js/ directory. +4. Hugo claimed that it created 0 pages. It created a file and copied over static files, but didn't create any pages. That's because it considers a "page" to be a file created directly from a content file. It doesn't count things like the index.html files that it creates automatically. + +#### The Home Page + +Hugo supports many different types of templates. The home page is special because it gets its own type of template and its own template file. The file, layouts/index.html, is used to generate the HTML for the home page. The Hugo documentation says that this is the only required template, but that depends. Hugo's warning message shows that it looks for three different templates: + +``` +WARN: 2014/09/29 Unable to locate layout: [index.html _default/list.html _default/single.html] +``` + +If it can't find any of these, it completely skips creating the home page. We noticed that when we built the site without having a theme installed. + +When Hugo created our theme, it created an empty home page template. Now, when we build the site, Hugo finds the template and uses it to generate the HTML for the home page. Since the template file is empty, the HTML file is empty, too. If the template had any rules in it, then Hugo would have used them to generate the home page. + +``` +$ find . -name index.html | xargs ls -l +-rw-r--r-- 1 quoha staff 0 Sep 29 20:21 ./public/index.html +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 ./themes/zafta/layouts/index.html +$ +``` + +#### The Magic of Static + +Hugo does two things when generating the site. It uses templates to transform content into HTML and it copies static files into the site. Unlike content, static files are not transformed. They are copied exactly as they are. + +Hugo assumes that your site will use both CSS and JavaScript, so it creates directories in your theme to hold them. Remember opinions? Well, Hugo's opinion is that you'll store your CSS in a directory named css/ and your JavaScript in a directory named js/. If you don't like that, you can change the directory names in your theme directory or even delete them completely. Hugo's nice enough to offer its opinion, then behave nicely if you disagree. + +``` +$ find themes/zafta -type d | xargs ls -ld +drwxr-xr-x 7 quoha staff 238 Sep 29 17:38 themes/zafta +drwxr-xr-x 3 quoha staff 102 Sep 29 17:31 themes/zafta/archetypes +drwxr-xr-x 5 quoha staff 170 Sep 29 17:31 themes/zafta/layouts +drwxr-xr-x 4 quoha staff 136 Sep 29 17:31 themes/zafta/layouts/_default +drwxr-xr-x 4 quoha staff 136 Sep 29 17:31 themes/zafta/layouts/partials +drwxr-xr-x 4 quoha staff 136 Sep 29 17:31 themes/zafta/static +drwxr-xr-x 2 quoha staff 68 Sep 29 17:31 themes/zafta/static/css +drwxr-xr-x 2 quoha staff 68 Sep 29 17:31 themes/zafta/static/js +$ +``` + +## The Theme Development Cycle + +When you're working on a theme, you will make changes in the theme's directory, rebuild the site, and check your changes in the browser. Hugo makes this very easy: + +1. Purge the public/ directory. +2. Run the built in web server in watch mode. +3. Open your site in a browser. +4. Update the theme. +5. Glance at your browser window to see changes. +6. Return to step 4. + +I’ll throw in one more opinion: never work on a theme on a live site. Always work on a copy of your site. Make changes to your theme, test them, then copy them up to your site. For added safety, use a tool like Git to keep a revision history of your content and your theme. Believe me when I say that it is too easy to lose both your mind and your changes. + +Check the main Hugo site for information on using Git with Hugo. + +### Purge the public/ Directory + +When generating the site, Hugo will create new files and update existing ones in the ```public/``` directory. It will not delete files that are no longer used. For example, files that were created in the wrong directory or with the wrong title will remain. If you leave them, you might get confused by them later. I recommend cleaning out your site prior to generating it. + +Note: If you're building on an SSD, you should ignore this. Churning on a SSD can be costly. + +### Hugo's Watch Option + +Hugo's "`--watch`" option will monitor the content/ and your theme directories for changes and rebuild the site automatically. + +### Live Reload + +Hugo's built in web server supports live reload. As pages are saved on the server, the browser is told to refresh the page. Usually, this happens faster than you can say, "Wow, that's totally amazing." + +### Development Commands + +Use the following commands as the basis for your workflow. + +``` +## purge old files. hugo will recreate the public directory. +## +$ rm -rf public +## +## run hugo in watch mode +## +$ hugo server --watch --verbose +``` + +Here's sample output showing Hugo detecting a change to the template for the home page. Once generated, the web browser automatically reloaded the page. I've said this before, it's amazing. + + +``` +$ rm -rf public +$ hugo server --watch --verbose +INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/ +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ +WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] +0 draft content +0 future content +0 pages created +0 tags created +0 categories created +in 2 ms +Watching for changes in /Users/quoha/Sites/zafta/content +Serving pages from /Users/quoha/Sites/zafta/public +Web Server is available at http://localhost:1313 +Press Ctrl+C to stop +INFO: 2014/09/29 File System Event: ["/Users/quoha/Sites/zafta/themes/zafta/layouts/index.html": MODIFY|ATTRIB] +Change detected, rebuilding site + +WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] +0 draft content +0 future content +0 pages created +0 tags created +0 categories created +in 1 ms +``` + +## Update the Home Page Template + +The home page is one of a few special pages that Hugo creates automatically. As mentioned earlier, it looks for one of three files in the theme's layout/ directory: + +1. index.html +2. _default/list.html +3. _default/single.html + +We could update one of the default templates, but a good design decision is to update the most specific template available. That's not a hard and fast rule (in fact, we'll break it a few times in this tutorial), but it is a good generalization. + +### Make a Static Home Page + +Right now, that page is empty because we don't have any content and we don't have any logic in the template. Let's change that by adding some text to the template. + +``` +$ vi themes/zafta/layouts/index.html + + + +

hugo says hello!

+ + +:wq + +$ +``` + +Build the web site and then verify the results. + +``` +$ hugo --verbose +INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/ +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ +WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] +0 draft content +0 future content +0 pages created +0 tags created +0 categories created +in 2 ms + +$ find public -type f -name '*.html' | xargs ls -l +-rw-r--r-- 1 quoha staff 78 Sep 29 21:26 public/index.html + +$ cat public/index.html + + + +

hugo says hello!

+ +``` + +#### Live Reload + +Note: If you're running the server with the `--watch` option, you'll see different content in the file: + +``` +$ cat public/index.html + + + +

hugo says hello!

+ + +``` + +When you use `--watch`, the Live Reload script is added by Hugo. Look for live reload in the documentation to see what it does and how to disable it. + +### Build a "Dynamic" Home Page + +"Dynamic home page?" Hugo's a static web site generator, so this seems an odd thing to say. I mean let's have the home page automatically reflect the content in the site every time Hugo builds it. We'll use iteration in the template to do that. + +#### Create New Posts + +Now that we have the home page generating static content, let's add some content to the site. We'll display these posts as a list on the home page and on their own page, too. + +Hugo has a command to generate a skeleton post, just like it does for sites and themes. + +``` +$ hugo --verbose new post/first.md +INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml +INFO: 2014/09/29 attempting to create post/first.md of post +INFO: 2014/09/29 curpath: /Users/quoha/Sites/zafta/themes/zafta/archetypes/default.md +ERROR: 2014/09/29 Unable to Cast to map[string]interface{} + +$ +``` + +That wasn't very nice, was it? + +The "new" command uses an archetype to create the post file. Hugo created an empty default archetype file, but that causes an error when there's a theme. For me, the workaround was to create an archetypes file specifically for the post type. + +``` +$ vi themes/zafta/archetypes/post.md ++++ +Description = "" +Tags = [] +Categories = [] ++++ +:wq + +$ find themes/zafta/archetypes -type f | xargs ls -l +-rw-r--r-- 1 quoha staff 0 Sep 29 21:53 themes/zafta/archetypes/default.md +-rw-r--r-- 1 quoha staff 51 Sep 29 21:54 themes/zafta/archetypes/post.md + +$ hugo --verbose new post/first.md +INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml +INFO: 2014/09/29 attempting to create post/first.md of post +INFO: 2014/09/29 curpath: /Users/quoha/Sites/zafta/themes/zafta/archetypes/post.md +INFO: 2014/09/29 creating /Users/quoha/Sites/zafta/content/post/first.md +/Users/quoha/Sites/zafta/content/post/first.md created + +$ hugo --verbose new post/second.md +INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml +INFO: 2014/09/29 attempting to create post/second.md of post +INFO: 2014/09/29 curpath: /Users/quoha/Sites/zafta/themes/zafta/archetypes/post.md +INFO: 2014/09/29 creating /Users/quoha/Sites/zafta/content/post/second.md +/Users/quoha/Sites/zafta/content/post/second.md created + +$ ls -l content/post +total 16 +-rw-r--r-- 1 quoha staff 104 Sep 29 21:54 first.md +-rw-r--r-- 1 quoha staff 105 Sep 29 21:57 second.md + +$ cat content/post/first.md ++++ +Categories = [] +Description = "" +Tags = [] +date = "2014-09-29T21:54:53-05:00" +title = "first" + ++++ +my first post + +$ cat content/post/second.md ++++ +Categories = [] +Description = "" +Tags = [] +date = "2014-09-29T21:57:09-05:00" +title = "second" + ++++ +my second post + +$ +``` + +Build the web site and then verify the results. + +``` +$ rm -rf public +$ hugo --verbose +INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/ +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ +INFO: 2014/09/29 found taxonomies: map[string]string{"category":"categories", "tag":"tags"} +WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] +0 draft content +0 future content +2 pages created +0 tags created +0 categories created +in 4 ms +$ +``` + +The output says that it created 2 pages. Those are our new posts: + +``` +$ find public -type f -name '*.html' | xargs ls -l +-rw-r--r-- 1 quoha staff 78 Sep 29 22:13 public/index.html +-rw-r--r-- 1 quoha staff 0 Sep 29 22:13 public/post/first/index.html +-rw-r--r-- 1 quoha staff 0 Sep 29 22:13 public/post/index.html +-rw-r--r-- 1 quoha staff 0 Sep 29 22:13 public/post/second/index.html +$ +``` + +The new files are empty because because the templates used to generate the content are empty. The homepage doesn't show the new content, either. We have to update the templates to add the posts. + +### List and Single Templates + +In Hugo, we have three major kinds of templates. There's the home page template that we updated previously. It is used only by the home page. We also have "single" templates which are used to generate output for a single content file. We also have "list" templates that are used to group multiple pieces of content before generating output. + +Generally speaking, list templates are named "list.html" and single templates are named "single.html." + +There are three other types of templates: partials, content views, and terms. We will not go into much detail on these. + +### Add Content to the Homepage + +The home page will contain a list of posts. Let's update its template to add the posts that we just created. The logic in the template will run every time we build the site. + +``` +$ vi themes/zafta/layouts/index.html + + + + {{ range first 10 .Data.Pages }} +

{{ .Title }}

+ {{ end }} + + +:wq + +$ +``` + +Hugo uses the Go template engine. That engine scans the template files for commands which are enclosed between "{{" and "}}". In our template, the commands are: + +1. range +2. .Title +3. end + +The "range" command is an iterator. We're going to use it to go through the first ten pages. Every HTML file that Hugo creates is treated as a page, so looping through the list of pages will look at every file that will be created. + +The ".Title" command prints the value of the "title" variable. Hugo pulls it from the front matter in the Markdown file. + +The "end" command signals the end of the range iterator. The engine loops back to the top of the iteration when it finds "end." Everything between the "range" and "end" is evaluated every time the engine goes through the iteration. In this file, that would cause the title from the first ten pages to be output as heading level one. + +It's helpful to remember that some variables, like .Data, are created before any output files. Hugo loads every content file into the variable and then gives the template a chance to process before creating the HTML files. + +Build the web site and then verify the results. + +``` +$ rm -rf public +$ hugo --verbose +INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/ +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ +INFO: 2014/09/29 found taxonomies: map[string]string{"tag":"tags", "category":"categories"} +WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] +0 draft content +0 future content +2 pages created +0 tags created +0 categories created +in 4 ms +$ find public -type f -name '*.html' | xargs ls -l +-rw-r--r-- 1 quoha staff 94 Sep 29 22:23 public/index.html +-rw-r--r-- 1 quoha staff 0 Sep 29 22:23 public/post/first/index.html +-rw-r--r-- 1 quoha staff 0 Sep 29 22:23 public/post/index.html +-rw-r--r-- 1 quoha staff 0 Sep 29 22:23 public/post/second/index.html +$ cat public/index.html + + + + +

second

+ +

first

+ + + +$ +``` + +Congratulations, the home page shows the title of the two posts. The posts themselves are still empty, but let's take a moment to appreciate what we've done. Your template now generates output dynamically. Believe it or not, by inserting the range command inside of those curly braces, you've learned everything you need to know to build a theme. All that's really left is understanding which template will be used to generate each content file and becoming familiar with the commands for the template engine. + +And, if that were entirely true, this tutorial would be much shorter. There are a few things to know that will make creating a new template much easier. Don't worry, though, that's all to come. + +### Add Content to the Posts + +We're working with posts, which are in the content/post/ directory. That means that their section is "post" (and if we don't do something weird, their type is also "post"). + +Hugo uses the section and type to find the template file for every piece of content. Hugo will first look for a template file that matches the section or type name. If it can't find one, then it will look in the _default/ directory. There are some twists that we'll cover when we get to categories and tags, but for now we can assume that Hugo will try post/single.html, then _default/single.html. + +Now that we know the search rule, let's see what we actually have available: + +``` +$ find themes/zafta -name single.html | xargs ls -l +-rw-r--r-- 1 quoha staff 132 Sep 29 17:31 themes/zafta/layouts/_default/single.html +``` + +We could create a new template, post/single.html, or change the default. Since we don't know of any other content types, let's start with updating the default. + +Remember, any content that we haven't created a template for will end up using this template. That can be good or bad. Bad because I know that we're going to be adding different types of content and we're going to end up undoing some of the changes we've made. It's good because we'll be able to see immediate results. It's also good to start here because we can start to build the basic layout for the site. As we add more content types, we'll refactor this file and move logic around. Hugo makes that fairly painless, so we'll accept the cost and proceed. + +Please see the Hugo documentation on template rendering for all the details on determining which template to use. And, as the docs mention, if you're building a single page application (SPA) web site, you can delete all of the other templates and work with just the default single page. That's a refreshing amount of joy right there. + +#### Update the Template File + +``` +$ vi themes/zafta/layouts/_default/single.html + + + + {{ .Title }} + + +

{{ .Title }}

+ {{ .Content }} + + +:wq + +$ +``` + +Build the web site and verify the results. + +``` +$ rm -rf public +$ hugo --verbose +INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/ +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ +INFO: 2014/09/29 found taxonomies: map[string]string{"tag":"tags", "category":"categories"} +WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] +0 draft content +0 future content +2 pages created +0 tags created +0 categories created +in 4 ms + +$ find public -type f -name '*.html' | xargs ls -l +-rw-r--r-- 1 quoha staff 94 Sep 29 22:40 public/index.html +-rw-r--r-- 1 quoha staff 125 Sep 29 22:40 public/post/first/index.html +-rw-r--r-- 1 quoha staff 0 Sep 29 22:40 public/post/index.html +-rw-r--r-- 1 quoha staff 128 Sep 29 22:40 public/post/second/index.html + +$ cat public/post/first/index.html + + + + first + + +

first

+

my first post

+ + + + +$ cat public/post/second/index.html + + + + second + + +

second

+

my second post

+ + + +$ +``` + +Notice that the posts now have content. You can go to localhost:1313/post/first to verify. + +### Linking to Content + +The posts are on the home page. Let's add a link from there to the post. Since this is the home page, we'll update its template. + +``` +$ vi themes/zafta/layouts/index.html + + + + {{ range first 10 .Data.Pages }} +

{{ .Title }}

+ {{ end }} + + +``` + +Build the web site and verify the results. + +``` +$ rm -rf public +$ hugo --verbose +INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/ +INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ +INFO: 2014/09/29 found taxonomies: map[string]string{"tag":"tags", "category":"categories"} +WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] +0 draft content +0 future content +2 pages created +0 tags created +0 categories created +in 4 ms + +$ find public -type f -name '*.html' | xargs ls -l +-rw-r--r-- 1 quoha staff 149 Sep 29 22:44 public/index.html +-rw-r--r-- 1 quoha staff 125 Sep 29 22:44 public/post/first/index.html +-rw-r--r-- 1 quoha staff 0 Sep 29 22:44 public/post/index.html +-rw-r--r-- 1 quoha staff 128 Sep 29 22:44 public/post/second/index.html + +$ cat public/index.html + + + + +

second

+ +

first

+ + + + +$ +``` + +### Create a Post Listing + +We have the posts displaying on the home page and on their own page. We also have a file public/post/index.html that is empty. Let's make it show a list of all posts (not just the first ten). + +We need to decide which template to update. This will be a listing, so it should be a list template. Let's take a quick look and see which list templates are available. + +``` +$ find themes/zafta -name list.html | xargs ls -l +-rw-r--r-- 1 quoha staff 0 Sep 29 17:31 themes/zafta/layouts/_default/list.html +``` + +As with the single post, we have to decide to update _default/list.html or create post/list.html. We still don't have multiple content types, so let's stay consistent and update the default list template. + +## Creating Top Level Pages + +Let's add an "about" page and display it at the top level (as opposed to a sub-level like we did with posts). + +The default in Hugo is to use the directory structure of the content/ directory to guide the location of the generated html in the public/ directory. Let's verify that by creating an "about" page at the top level: + +``` +$ vi content/about.md ++++ +title = "about" +description = "about this site" +date = "2014-09-27" +slug = "about time" ++++ + +## about us + +i'm speechless +:wq +``` + +Generate the web site and verify the results. + +``` +$ find public -name '*.html' | xargs ls -l +-rw-rw-r-- 1 mdhender staff 334 Sep 27 15:08 public/about-time/index.html +-rw-rw-r-- 1 mdhender staff 527 Sep 27 15:08 public/index.html +-rw-rw-r-- 1 mdhender staff 358 Sep 27 15:08 public/post/first-post/index.html +-rw-rw-r-- 1 mdhender staff 0 Sep 27 15:08 public/post/index.html +-rw-rw-r-- 1 mdhender staff 342 Sep 27 15:08 public/post/second-post/index.html +``` + +Notice that the page wasn't created at the top level. It was created in a sub-directory named 'about-time/'. That name came from our slug. Hugo will use the slug to name the generated content. It's a reasonable default, by the way, but we can learn a few things by fighting it for this file. + +One other thing. Take a look at the home page. + +``` +$ cat public/index.html + + + +

creating a new theme

+

about

+

second

+

first

+ + +``` + +Notice that the "about" link is listed with the posts? That's not desirable, so let's change that first. + +``` +$ vi themes/zafta/layouts/index.html + + + +

posts

+ {{ range first 10 .Data.Pages }} + {{ if eq .Type "post"}} +

{{ .Title }}

+ {{ end }} + {{ end }} + +

pages

+ {{ range .Data.Pages }} + {{ if eq .Type "page" }} +

{{ .Title }}

+ {{ end }} + {{ end }} + + +:wq +``` + +Generate the web site and verify the results. The home page has two sections, posts and pages, and each section has the right set of headings and links in it. + +But, that about page still renders to about-time/index.html. + +``` +$ find public -name '*.html' | xargs ls -l +-rw-rw-r-- 1 mdhender staff 334 Sep 27 15:33 public/about-time/index.html +-rw-rw-r-- 1 mdhender staff 645 Sep 27 15:33 public/index.html +-rw-rw-r-- 1 mdhender staff 358 Sep 27 15:33 public/post/first-post/index.html +-rw-rw-r-- 1 mdhender staff 0 Sep 27 15:33 public/post/index.html +-rw-rw-r-- 1 mdhender staff 342 Sep 27 15:33 public/post/second-post/index.html +``` + +Knowing that hugo is using the slug to generate the file name, the simplest solution is to change the slug. Let's do it the hard way and change the permalink in the configuration file. + +``` +$ vi config.toml +[permalinks] + page = "/:title/" + about = "/:filename/" +``` + +Generate the web site and verify that this didn't work. Hugo lets "slug" or "URL" override the permalinks setting in the configuration file. Go ahead and comment out the slug in content/about.md, then generate the web site to get it to be created in the right place. + +## Sharing Templates + +If you've been following along, you probably noticed that posts have titles in the browser and the home page doesn't. That's because we didn't put the title in the home page's template (layouts/index.html). That's an easy thing to do, but let's look at a different option. + +We can put the common bits into a shared template that's stored in the themes/zafta/layouts/partials/ directory. + +### Create the Header and Footer Partials + +In Hugo, a partial is a sugar-coated template. Normally a template reference has a path specified. Partials are different. Hugo searches for them along a TODO defined search path. This makes it easier for end-users to override the theme's presentation. + +``` +$ vi themes/zafta/layouts/partials/header.html + + + + {{ .Title }} + + +:wq + +$ vi themes/zafta/layouts/partials/footer.html + + +:wq +``` + +### Update the Home Page Template to Use the Partials + +The most noticeable difference between a template call and a partials call is the lack of path: + +``` +{{ template "theme/partials/header.html" . }} +``` +versus +``` +{{ partial "header.html" . }} +``` +Both pass in the context. + +Let's change the home page template to use these new partials. + +``` +$ vi themes/zafta/layouts/index.html +{{ partial "header.html" . }} + +

posts

+ {{ range first 10 .Data.Pages }} + {{ if eq .Type "post"}} +

{{ .Title }}

+ {{ end }} + {{ end }} + +

pages

+ {{ range .Data.Pages }} + {{ if or (eq .Type "page") (eq .Type "about") }} +

{{ .Type }} - {{ .Title }} - {{ .RelPermalink }}

+ {{ end }} + {{ end }} + +{{ partial "footer.html" . }} +:wq +``` + +Generate the web site and verify the results. The title on the home page is now "your title here", which comes from the "title" variable in the config.toml file. + +### Update the Default Single Template to Use the Partials + +``` +$ vi themes/zafta/layouts/_default/single.html +{{ partial "header.html" . }} + +

{{ .Title }}

+ {{ .Content }} + +{{ partial "footer.html" . }} +:wq +``` + +Generate the web site and verify the results. The title on the posts and the about page should both reflect the value in the markdown file. + +## Add “Date Published” to Posts + +It's common to have posts display the date that they were written or published, so let's add that. The front matter of our posts has a variable named "date." It's usually the date the content was created, but let's pretend that's the value we want to display. + +### Add “Date Published” to the Template + +We'll start by updating the template used to render the posts. The template code will look like: + +``` +{{ .Date.Format "Mon, Jan 2, 2006" }} +``` + +Posts use the default single template, so we'll change that file. + +``` +$ vi themes/zafta/layouts/_default/single.html +{{ partial "header.html" . }} + +

{{ .Title }}

+

{{ .Date.Format "Mon, Jan 2, 2006" }}

+ {{ .Content }} + +{{ partial "footer.html" . }} +:wq +``` + +Generate the web site and verify the results. The posts now have the date displayed in them. There's a problem, though. The "about" page also has the date displayed. + +As usual, there are a couple of ways to make the date display only on posts. We could do an "if" statement like we did on the home page. Another way would be to create a separate template for posts. + +The "if" solution works for sites that have just a couple of content types. It aligns with the principle of "code for today," too. + +Let's assume, though, that we've made our site so complex that we feel we have to create a new template type. In Hugo-speak, we're going to create a section template. + +Let's restore the default single template before we forget. + +``` +$ mkdir themes/zafta/layouts/post +$ vi themes/zafta/layouts/_default/single.html +{{ partial "header.html" . }} + +

{{ .Title }}

+ {{ .Content }} + +{{ partial "footer.html" . }} +:wq +``` + +Now we'll update the post's version of the single template. If you remember Hugo's rules, the template engine will use this version over the default. + +``` +$ vi themes/zafta/layouts/post/single.html +{{ partial "header.html" . }} + +

{{ .Title }}

+

{{ .Date.Format "Mon, Jan 2, 2006" }}

+ {{ .Content }} + +{{ partial "footer.html" . }} +:wq + +``` + +Note that we removed the date logic from the default template and put it in the post template. Generate the web site and verify the results. Posts have dates and the about page doesn't. + +### Don't Repeat Yourself + +DRY is a good design goal and Hugo does a great job supporting it. Part of the art of a good template is knowing when to add a new template and when to update an existing one. While you're figuring that out, accept that you'll be doing some refactoring. Hugo makes that easy and fast, so it's okay to delay splitting up a template. diff --git a/themes/Gregroad/exampleSite/content/post/goisforlovers.md b/themes/Gregroad/exampleSite/content/post/goisforlovers.md new file mode 100644 index 0000000..4bcc80d --- /dev/null +++ b/themes/Gregroad/exampleSite/content/post/goisforlovers.md @@ -0,0 +1,343 @@ +--- +title: "(Hu)go Template Primer" +date: 2014-04-02 +thumbnail: "img/placeholder.png" +tags: + - "go" + - "golang" + - "templates" + - "themes" + - "development" +categories: + - "Development" + - "golang" +--- + +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. + + + +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 + +Golang 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 }} + +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" }}

{{ index .Params "title" }}

{{ 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 }}

{{ . }}

{{ 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 }} +
  • {{ . }} - {{ $title }}
  • + {{ 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 }} +
    + {{ .TableOfContents }} +
    + {{ 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 `