summaryrefslogtreecommitdiffstats
path: root/helpers/content.go
AgeCommit message (Collapse)Author
2018-06-10Add support for theme composition and inheritanceBjørn Erik Pedersen
This commit adds support for theme composition and inheritance in Hugo. With this, it helps thinking about a theme as a set of ordered components: ```toml theme = ["my-shortcodes", "base-theme", "hyde"] ``` The theme definition example above in `config.toml` creates a theme with the 3 components with presedence from left to right. So, Hugo will, for any given file, data entry etc., look first in the project, and then in `my-shortcode`, `base-theme` and lastly `hyde`. Hugo uses two different algorithms to merge the filesystems, depending on the file type: * For `i18n` and `data` files, Hugo merges deeply using the translation id and data key inside the files. * For `static`, `layouts` (templates) and `archetypes` files, these are merged on file level. So the left-most file will be chosen. The name used in the `theme` definition above must match a folder in `/your-site/themes`, e.g. `/your-site/themes/my-shortcodes`. There are plans to improve on this and get a URL scheme so this can be resolved automatically. Also note that a component that is part of a theme can have its own configuration file, e.g. `config.toml`. There are currently some restrictions to what a theme component can configure: * `params` (global and per language) * `menu` (global and per language) * `outputformats` and `mediatypes` The same rules apply here: The left-most param/menu etc. with the same ID will win. There are some hidden and experimental namespace support in the above, which we will work to improve in the future, but theme authors are encouraged to create their own namespaces to avoid naming conflicts. A final note: Themes/components can also have a `theme` definition in their `config.toml` and similar, which is the "inheritance" part of this commit's title. This is currently not supported by the Hugo theme site. We will have to wait for some "auto dependency" feature to be implemented for that to happen, but this can be a powerful feature if you want to create your own theme-variant based on others. Fixes #4460 Fixes #4450
2018-05-29Add a BlackFriday option for rel="noreferrer" on external linksStefan Neuhaus
Add a configuration option "noreferrerLinks". When set to "true" the "HTML_NOREFERRER_LINKS" flag is being passed to Blackfriday. Thereby all *absolute* links will get a "noreferrer" value for their "rel" attribute. See #4722
2018-05-28Add a BlackFriday option for rel="nofollow" on external linksStefan Neuhaus
Add a configuration option "nofollowLinks". When set to "true" the "HTML_NOFOLLOW_LINKS" flag is being passed to Blackfriday. Thereby all *absolute* links will get a "nofollow" value for the "rel" attribute. Fixes #4722
2018-04-29Fix .WordCount, .FuzzyWordCount, .ReadingTime when summary marker is setBjørn Erik Pedersen
This bug was introduced in Hugo 0.40. It is when you use the `<!--more-->` summary marker. Note that this affects the word stats only. The related `PlainWords`, `Plain`, `Content` all return correct values. Fixes #4675 Fixes #4682
2018-04-21Make .Content (almost) always available in shortcodesBjørn Erik Pedersen
This resolves some surprising behaviour when reading other pages' content from shortcodes. Before this commit, that behaviour was undefined. Note that this has never been an issue from regular templates. It will still not be possible to get **the current shortcode's page's rendered content**. That would have impressed Einstein. The new and well defined rules are: * `.Page.Content` from a shortcode will be empty. The related `.Page.Truncated` `.Page.Summary`, `.Page.WordCount`, `.Page.ReadingTime`, `.Page.Plain` and `.Page.PlainWords` will also have empty values. * For _other pages_ (retrieved via `.Page.Site.GetPage`, `.Site.Pages` etc.) the `.Content` is there to use as you please as long as you don't have infinite content recursion in your shortcode/content setup. See below. * `.Page.TableOfContents` is good to go (but does not support shortcodes in headlines; this is unchanged) If you get into a situation of infinite recursion, the `.Content` will be empty. Run `hugo -v` for more information. Fixes #4632 Fixes #4653 Fixes #4655
2017-12-27:sparkles: Implement Page bundling and image handlingBjørn Erik Pedersen
This commit is not the smallest in Hugo's history. Some hightlights include: * Page bundles (for complete articles, keeping images and content together etc.). * Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`. * Processed images are cached inside `resources/_gen/images` (default) in your project. * Symbolic links (both files and dirs) are now allowed anywhere inside /content * A new table based build summary * The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below). A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory: ```bash ▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render" benchmark old ns/op new ns/op delta BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30% BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86% benchmark old allocs new allocs delta BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47% BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30% benchmark old bytes new bytes delta BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12% BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64% ``` Fixes #3651 Closes #3158 Fixes #1014 Closes #2021 Fixes #1240 Updates #3757
2017-12-16Reuse the BlackFriday instance when possibleBjørn Erik Pedersen
This is in heavy use in rendering, so this makes a difference: ```bash benchmark old ns/op new ns/op delta BenchmarkSiteBuilding/TOML,num_langs=1,num_pages=500,tags_per_page=5,shortcodes,render-4 124551144 107743429 -13.49% benchmark old allocs new allocs delta BenchmarkSiteBuilding/TOML,num_langs=1,num_pages=500,tags_per_page=5,shortcodes,render-4 528684 435118 -17.70% benchmark old bytes new bytes delta BenchmarkSiteBuilding/TOML,num_langs=1,num_pages=500,tags_per_page=5,shortcodes,render-4 53306848 45147832 -15.31% ```
2017-11-30Add Pandoc support, refactor external helpersBrian Chen
Recognize the Pandoc format under the file extension .pandoc or .pdc, and shell out to pandoc as an external helper to format Pandoc content. Refactor out repeated code with external helpers. Change the error output formatting. I did not see any of the external helpers print the string "<input>" to represent stdin as a file; just prepending the file name to error output is more general and doesn't sacrifice that much in terms of readability. Closes #234
2017-09-29Change SummaryLength to be configurable (#3924)Brendan Roy
Move SummaryLength into the ContentSpec struct and refactor the relevant summary functions to be methods of ContentSpec. The new summaryLength struct member is configurable by the summaryLength config value, and the default remains 70. Also updates hugolib/page to use the refactored methods. Resolves #3734
2017-09-25Use Chroma as new default syntax highlighterBjørn Erik Pedersen
If you want to use Pygments, set `pygmentsUseClassic=true` in your site config. Fixes #3888
2017-08-03Add some missing doc commentsJorin Vogel
As pointed out by the linter, some exported functions and types are missing doc comments. The linter warnings have been reduced from 194 to 116. Not all missing comments have been added in this commit though.
2017-08-02Remove sourceRelativeLinksBjørn Erik Pedersen
Fixes #3766
2017-07-29helpers: Add support for French GuillemetsBjørn Erik Pedersen
Fixes #3725
2017-07-21helpers: Add --trace to asciidoctor argsVasyl Solovei
This will help to understand and fix errors by seeing stacktrace of an error. See #3714
2017-06-27helpers: Add Blackfriday 'joinLines' extension support (#3574)Haishan Zhou
See https://github.com/russross/blackfriday/pull/334 "add an extension to handle Chinese (or CJK) newlines" for more information.
2017-06-27helpers: add --initial-header-level=2 to rst2html (#3528)Frank Braun
reStructuredText doesn't have explicit section levels but sets them in the order of appearance. Since level 1 is already set from the title in the front matter it makes more sense to start with level 2 when converting with rst2html.
2017-06-13Run gofmt to get imports in line vs gohugoio/hugoBjørn Erik Pedersen
2017-06-13all: Update import paths to gohugoio/hugoBjørn Erik Pedersen
2017-04-22helpers: Delete RenderingContext.getConfigAlbert Nigmatzianov
2017-04-06helpers: Add new properties to ContentSpecAlbert Nigmatzianov
2017-02-21all: Add org-mode supportChase Adams
Fixes #1483 See #936
2017-02-17all: Refactor to nonglobal Viper, i18n etc.Bjørn Erik Pedersen
This is a final rewrite that removes all the global state in Hugo, which also enables the use if `t.Parallel` in tests. Updates #2701 Fixes #3016
2017-02-11Deprecate sourceRelativeLinksBjørn Erik Pedersen
Fixes #3028 Closes #3026 Closes #2891 Closes #2691
2017-01-05helpers: Remove unusded WordCountBjørn Erik Pedersen
2017-01-01Fix Appveyor Windows build and GitInfo path issue on WindowsDavid Kassa
2016-10-24all: Unify case of config variable namesAlbert Nigmatzianov
All config variables starts with low-case and uses camelCase. If there is abbreviation at the beginning of the name, the whole abbreviation will be written in low-case. If there is abbreviation at the end of the name, the whole abbreviation will be written in upper-case. For example, rssURI.
2016-10-19Add page context to error logging in renderingchoeppler
Add logging of the errors/warnings which rst2html outputs to its stderr stream when rendering rst documents. Note that rst2html outputs warnings and errors to stderr but it also adds them to the generated html. -> hugo logs everything in stderr as error. Add / complete adding page context (path to file being rendered) to anything logged by getRstContent and getAsciidocContent. See #2570
2016-10-16Fix case issue Viper vs Blackfriday configBjørn Erik Pedersen
There are still work to be done in the case department, but that will have to be another day. Fixes #2581 See https://github.com/spf13/viper/issues/261
2016-10-13Add context to asciidoc/-tor error loggingC. Hoeppler
Add DocumentName (path to the file being rendered) to RenderingContext and use that information to include the path in the error print. See #2399 Closes #2567
2016-10-13Add logging of asciidoc/-tor errorsC. Hoeppler
Add logging of the errors which asciidoc and asciidoctor output to their stderr stream when converting asciidoc documents. Note that asciidoctor's exit code may be SUCCESS even if there are ERROR messages in its stderr output (tested with Asciidoctor 0.1.4 and 1.5.5). Therefore log the stderr output whenever it is non-empty. See #2399
2016-09-19Remove some unused varsBjørn Erik Pedersen
2016-09-14Lazy calculate WordCount, ReadingTime and FuzzyWordCountBjørn Erik Pedersen
This avoids having to execute these expensive operations for sites not using these values. This commit sums up a set of wordcounting and autosummary related performance improvements. The effect of these kind of depends on what features your site use, but a benchmark from 4 Hugo sites in the wild shows promise: ``` benchmark old ns/op new ns/op delta BenchmarkHugo-4 21293005843 20032857342 -5.92% benchmark old allocs new allocs delta BenchmarkHugo-4 65290922 65186032 -0.16% benchmark old bytes new bytes delta BenchmarkHugo-4 9771213416 9681866464 -0.91% ``` Closes #2378
2016-09-14Improve TotalWords counter funcBjørn Erik Pedersen
It is obviously more efficient when we do not care about the actual words. ``` BenchmarkTotalWords-4 100000 18795 ns/op 0 B/op 0 allocs/op BenchmarkTotalWordsOld-4 30000 46751 ns/op 6400 B/op 1 allocs/op ```
2016-09-14Avoid splitting words for summaryBjørn Erik Pedersen
For people using autogenerated summaries, this is one of the hot spots in the memory department. We don't need to split al the content into words to do proper summary truncation. This is obviously more effective: ``` BenchmarkTestTruncateWordsToWholeSentence-4 300000 4720 ns/op 0 B/op 0 allocs/op BenchmarkTestTruncateWordsToWholeSentenceOld-4 100000 17699 ns/op 3072 B/op 3 allocs/op ```
2016-09-09Add TODO list support for BlackfridayBjørn Erik Pedersen
* Add CSS class to TODO list and list items * Add a flag to turn task list support off Fixes #2269
2016-09-06Multilingual TODO-fixes, take 1Bjørn Erik Pedersen
See #2309
2016-09-06Make it possible to configure Blackfroday per languageBjørn Erik Pedersen
See #2309
2016-09-06Render the shortcodes as late as possibleBjørn Erik Pedersen
This is needed to make shortcode users happy with the new multilanguage support, but it will also solve many other related posts about "stuff not available in the shortcode". We will have to revisit this re the handler chain at some point, but that will be easier now as the integration test story has improved so much. As part of this commit, the site-building tests in page_test.go is refreshed, they now tests for all the rendering engines (when available), and all of them now uses the same code-path as used in production. Fixes #1229 Fixes #2323 Fixes ##1076
2016-07-22Simplify the configuration of HugoHTMLRendererBjørn Erik Pedersen
2016-07-10Revert "Use bufferpool in Asciidoc handler"Bjørn Erik Pedersen
This reverts commit 068a77151e27adb4106e86c407831ad6aa34ad8d. This was hasty. We would need to create a copy to use the pool in this case.
2016-07-10Revert "Use bufferpool in Rst handler"Bjørn Erik Pedersen
This reverts commit d9bc233f1f38df022864e0700a0514edf89b12d0. This was hasty. We would need to make a copy to use the pool in this case.
2016-07-10Use bufferpool in Rst handlerBjørn Erik Pedersen
2016-07-10Remove []byte to string to []byte conversion in RstBjørn Erik Pedersen
2016-07-10Use bufferpool in Asciidoc handlerBjørn Erik Pedersen
2016-07-10Remove []byte to string to []byte conversion in AsciidocBjørn Erik Pedersen
2016-07-10Consolidate the Render funcsBjørn Erik Pedersen
2016-07-04Add Rst shortcode testBjørn Erik Pedersen
Fixes #2253
2016-07-04Add Asciidoc shortcode testBjørn Erik Pedersen
Fixes #2249
2016-04-12Default to plainIDAnchorsBjørn Erik Pedersen
Fixes #2057
2016-04-12Revert "Use Node.ID for anchor ID"Bjørn Erik Pedersen
This reverts commit cd558958a0c0ecd06f7560a38e27334fe983e0de.