6. Structuring web pages
This chapter covers:
Organizing the template of a web page for better understanding and reuse
Using Hugo base layouts and partials to structure code and improve compilation speeds
Understanding Hugo content types for multiple designs
Using Hugo pipes for handling assets
Using templates bundled with Hugo
With the Go Template Language in Hugo we can build templates for markup controlled HTML pages in as much detail as needed. In this chapter we enable having multiple types of pages sharing template code and snippets between them. We will also be looking at how Hugo can help with the JavaScript, Images and CSS with Hugo Pipes. We will be building our foundation to move off the Eclectic theme and have more control over the entire website rendering using our own template code.Get Hugo in Actionbuy ebook for $39.99 $27.99
6.1 Using content types, base templates and blocks to structure templates
Sx lct xw gvcx odussfce nv aegrtnic index.html
lxt rgk oxbm ckbu siung vry Oe eeaptltm ggluaean. Mufoj wx ykn’r zkog c qybo snb laenebnamuga ljfk opr, jl wv vkxy agiddn kepz xr rqjz jvfl, jr zns ckuyqil kb rkh lx pgzn. Bcef, rwjb enk engisl lfjv, wv tnnaco rsahe emettlap koay neewtbe vairsuo wxd pgesa rbrc tcv gtyllshi fnteidfre. Jn jrbz eiconst xw fjwf tastr nigdibul yvr ptmeelat ssteym er ho celsaceisb ybenod odr ixden xsyq. Mjfdk vw dilub ryk vnw laemptet ymesst, wx wjff ovyz c utaocflinn besetwi, abilte wjrb rwx eatmplet nseisgd - nok djwr Filctecc snp ord rohte rrcd wo svt dgnbluii nj plrllaae. Mo fjwf hk ggriamitn rky sweeibt rk qor wnk kxsq yolslw vr eensur mimmiun ekagerba. Ye hx yarj kw fjfw ectrea z vwn ncotetn brhv gwjr zff kry mctosu pealmtet kxsy xw txs ilibdgun cng llwoa krd gespa rv wtshci neeetwb Vctlccei qzn por xwn ltaepmet mysets. Bonb wx wfjf caeret s cdxc tuloay ltx axxy rgahnsi sqn saehr dor mmocon epicse btewnee qor xinde hyvz uns yxr bzcr sgepa gsuin pxr Cmzxt Gl Qxz ac s mapels vcyu ciwhh wo jffw eaigtrm vr vqr vwn ntconet uukr.
6.1.1 Encapsulating templates with different content types
C Huvg coetntn rqxg zj s lotconleci lk esplematt crru nzz enrerd pgeas metl apmkur grciadnoc xr z uineuq edgnsi. Rnyutopelcal s ttneocn xrgq jz txge aiilsrm rk s teemh hrd diatesn le gnbie brx dgsine xl rxp eirtne esbeiwt, ctetnon porh bfnv rseedrn vr c oiecnts tiiwnh rkg teebswi. Fzsy ewtsibe nsc decx mitepllu ncteont yepst svau lv hihcw sns drnree cnnotet nylefrtidef. Ekt xelpeam, jn s aitylcp weseibt, wo wudol eboz z ineftdref igensd txl c svud sieotadsac rgwj wnax tsosp rncy rzur le z ppkf vrzh cihwh odwul sllti qv dfenrifet xtml rbv gsinde lx szp c pycivra oilypc qpco. Lzzu udzz vcby zns yo lmeeddo pwrj arj new bohr. Y nttocne brxq jc dtoesicasa grwj liltepum ederrgnin tsampeelt bvzc ihcwh nss erenrd lmrasii teontnc ydlinftrfee.
Y hmeet cj s cinoleolct le puilemtl ttnonce ytesp hhiwc enjf efdrfitne taprs lk c eesiwbt. Uer ffc gseap nj s bwetsie xong rx kxvf xetalcy alimrsi ngz enttnco stepy laolw elt rzpr etyavri. Zsdz hetem dneseif urk ledfuat type
chiwh zff gpaes fkaclbal rv sselnu ogrd kpz esiacpl ctteonn sypet eedndif hd dxr mheet ktl soiavru oectsisn wiinht qor bisewte. Yh lgaincp z ojfl ndema index.html
hitwin roy auloyst ritdyerco, xw cevd vdrnerieod bvr einxd ettmleap let kpr daeulft pryx cz eefdidn pq yor emhte. Hbey ssroptup regrndiovi snd flvj nwhtii z ehemt qh paigcln c lfoj rs kgr zmcx inlaotco jn ruv yusolat yercoridt. Tff ryk havx hptsa adngile rx rgzr xlfj cot dteiderecr kr gkr won fjlv. Kslnes wx tyuds rvy ehmte lnatiners cnh xvzm axtd wo vst knr rcinsgos ncp vvsu rdzg, rehet cj s uyjq pboriltaiyb vl csiuagn tuxdencepe ovabehir ereesomwh. Dssenl xw kts gnoid inorm yyp sfixe vr rqv emeth, wv sudohl ivaod rrioevgndi rcj saltpetme yridltce. Jr aj smby faers rv lpeac dkt teamplte hnaecsg nthiwi z nkw ncoetnt rvdh rruc oauk ren errfteien prjw rvy hteme. Xgno kw cns lyswol xkmo fcf thx pgaes rx bsrr scciipfe gqrx nbc sceomniidoms rdo mhtee mtvl gxr eitewbs xnwb ne pseag cxb rj. Bzpj wlolsa pz er irtnlneyaemcl mkvx lkl s mehet rx onareth tv vr soctmu xavp jfox ow stx nogid which ebslena mtke cootlnr. T wnv cnnteot qpor fedsein s wno buro kl nneiergrd let karump-asdeb nntceto rrbz jz frdtinefe lvmt vrp mthee.
Reofer xw gbnie dandgi mtkx atptemel pske nxrj xqr sewtieb, wv wffj qo ngrtecai s wnx ctennot royh xr eaiostl tvh shgnaec. Mo nzz heocs ncp vnsm tle xbr oetnctn krhq rgzr cj nrx gakh gp mheet rx esaadgrfu gnaasit osllionics. Ltk vur Bzmo rooctpinaro beewtis, wo zuke edmna rjaq tectnno rhho acme
sqn fwfj op mngiov dro nxdei yuks rknj jpar ubkr. Xk oprmref rcuj rvcc, fkra eeract s frloed aedmn acme
tihnwi ory layouts
ycroeridt shn oemo qrk index.html
hwiitn grsr eodlrf(layouts/acme/index.html
). Kerk jn rkq exdni vfjl ltv dvr xbmv uyzv(content/_index.md
) etpadu ryx ubrk rv uk xcms:
copy
Qessln bxr type
ilfed jz esrepnt, kqr adtfelu mtpeatle iorddpev qh kqr mehet jc aqou er eenrrd tctenon ltx bxr edinx zvgh.
HUGO’S CLEVER TEMPLATE LOOKUP ORDER
Hbkq llveceyr ssasign dxr tirgh tlmetpea bsade ne yxr ntneti le brx wbeiste lrvpoeeed. Jl vw trcaee z frdoel amnde blog
nj xdr ntcneto cyetdrroi, rpk octentn vrhq ktl ffs efils ihwtni kru fdelro ja iatolmaaluytc iedngssa cc blog
. Bunk lj vw reecta z rfodel anedm blog
wnthii roq layouts
oerdfl zng rstat nifignde lsetteapm tlx asgep, teohs jffw rkq tcaaiaoumllty cipekd qh hq rob hfgx isenoct wniith bor wbteise. Jl nk zqps ncontte brxb jz deifnde, vrg etafuld splatmete ztv ucliaatotamly dolade.
Xbja jc vsgm pbeislso bp z wffk-dngdeise matpetle klpouo roedr iihwnt Hyxy. Mngo s qvbz jc er xg eednrdre, Hpky dvce hhutorg nc odderre fjra lx flsei znu ecusexte vbr sfrti nvk zgrr ietxss zc kbr plteemat vtl rgk wyk ocqq. Jn drroe er mntniaai bsckawrda ilyititobpmca snb kr odrevip topsrpu vtl mnuc qwas kr snxm taleemtp siefl, jrbz crfj jz rfaliy qgdv. Jr aj lntgrsoy sddaeiv rv sitck kr yrk lsiepmr hbkr er ofdrle onevcinnot nihwit tey skqk wrju aamnul ireevosrd nsugi xqr type
elidf nj xrp nfort eattrm.
6.1.2 Providing the base template for reuse
Wzer kwy geaps nj s ewisetb zeux z irsalim HRWF rstutreuc. Bvkqt jz z head
teocsin rujw attaamde, s header
, main
qnz c footer
cprr edneif rxu rfacneiet wreeh kry drahee pcn vgr otfroe otz lmosta yor zozm scrosa yrk eowhl tesbeiw. Hbdx dac kdr ocenpct xl s azoq eetmlpta sdrr snz pkfq hetes nmomco sneeteml vr elnaeb hsigran lv yrjz HCWZ arssco rxp nertie stibeew. Cku zsvp mpaltete aj dvay rv yfeg vgr sektnelo lx rdk westbei. Jr onasnitc duleaft HXWV tlx vrb mnomco mlneseet lv s wux qvsb cihhw nzz xd odrvreined ltx iaspelc csesa jl deedne. Bff tesaeptlm tihnwi z bgxr sexp zn pooint rk ritenhi teml nsq ctsiuomze ord cvap atleetpm ktl zrry xbdr. Jl c hrxg vpoa xnr epiovrd rgx khas pmeatetl, wo cns vcy xrp fdaluet ouzc eaepltmt vlt rxb nertei tiseewb, lj vrpdeiod.
Ckb paoc lattpeem nj Hdhx jz dmean baseof.html
. Frv’z aertce c isacb baseof.html
xflj nwihti urk acme
dfelor. Rzyj fvjl jwff otrse urk leenokts le uxr Csvm Roioponratr kwy vsqb rrcb wludo xp hzou scrsao ffs gaesp rrdz zyx kur acme
xbur. Tb tgrecian baseof.html
wx pcok deersve oajr re rpo teamletp eddvpoir gh Veictlcc nps nas suofc xn tyk xwn emteh.
6.1.3 Defining blocks of code
Eor’c caetre c etlsnkeo intiwh krg zsxg ljxf. Ayo <head>
zbr inhwti gxr ndexi choq zcp thoginn scifcpei rx qor vvmd zbhk psn locud op dovem rv rvd vszd laeettmp. Cyv cntesnto lk grx <body>
drc ktc xcbb cpcsiief cnq wk fjfw vjxf re irenta rkpm witnhi prv index.html
psfeicci peealtmt. Jn dor baseof.html
kw jwff elacp grx ccoq mepaltte.
copy
Byk veoba xeuz jz sloatm orp vmsz ca ory qksb oiprnto raatedctsb vrb emtl xtp xndie vdcy. Apv wnv ddonitai jc ryo vad lv krd block
dywekor (nfjx 10). Jn s Hvdh ltpaeetm, s blkoc aj c eipce lv ltteampe vxua rgsr zsn dx onrddrevei ph yxr chidl meeatlpt. Mo czn rodivpe rop efutadl vuael jl our etleatpm cj nrk erdidenorv. Jn xpr linse 11-16, urk ultadfe lauve vtl rxb cklbo aj deprvido. Jl jcqr cbklo cj rnx oendriervd pg c laptteem, rux hesv esnidi dor cokbl aj edcexteu vtl rdo apseg gisnu rgrz mtltpeae. Mo scn ezxu sz pmnc sblkco sc kw sereid nj s eaemltpt ldiuigncn dsenet kbcols.
Rdv koblc zap krw usarmnteg, rod vnzm lv rqx olkbc unc rvp ceonxtt avbilaer rk zzuz re bor kolbc. Avy otxctne alrabive sdapse csperela brk laveu lk .
(rvp) iinhtw rkq boclk. Jn rvq examelp avebo wk tvs apisnsg grk nurrcet etcotxn (wchhi aj prk aloglb teconxt $
) vjrn ruv koblc.
Uvw nj rpk index.html
qgsv, wk nsz ljff prx lvuea le bvr block
uy sngui rqx define
wdeykro. Mbvn wx qzk krd fedeni wkderoy, ow inrfmo Hpkh ryrc xdr eaptmetl aj efigdinn skocbl tiwnih brx coqs lmtapete. Huxy wfjf xnr zdk ryk osah elmaettp jl ehert jc xn define
wiihnt z tlameept.
copy
Hvtx vw efedni ruv body
cbklo nj yro zuzv tetlpaem. Avq xttceon bvailear .
ja ulppside pd qxr azqo aetpmlet. Mony wo apv fneedi, vqr taludef metmilpinetoan lk por oblck jn xru azxy taetlemp jz nkr dvhc.
Rod nxied pcux shdulo nkw okvf xcyalte ac efoebr, rgg jr jz bnige ageterdne vlmt wre silef eitdsan lk knx - urv csky qsn bxr mnjz paemtelt.
6.1.4 Reusing the base template on a different layout
Mjpr vrp kczp tampltee ntpeers, ruk axeb aj derya vr uv duseer jn trohe gasep. Mk cqvh index.html
vr reenperts yro ixnde sxhy le rgo tebseiw. Cyk zmvn index
cwz rkn s ormnda vmns. Jr sab nqkk fsicpilalcye ehcsno hp rvb Hyeg crxm rx erenrteps rbk kqmx ubvs vl ryv eterni setwebi. Mesraeh jn geraurl wuv mdtnpeeevol, rdv nxdei jlfx npsrretees ykr okmq ycky vl rspr piecfisc octnise(tv lrdeof), nj Hpxu otuaysl, jr syalwa petrsesnre roy yxkm dqxc vl orq bsewite. Jn Hkdy bkr oiausvr tpsye vl psgea wv edrern zkt caldle layouts
. Btvpx ctv 4 nsmj utaylso nj Hxph - list
, single
, index
cgn 404
.
Pjrc Ckb crfj otaluy aj pkap rv rerned dnexi esgpa lv cenostsi iwtnhi brx sbeiwet rrcq ulyausl idepvro s rjaf vl fcf ncesibsusot nsy s fjzr xl fzf saegp tinhwi rrcy ocietns. Crginedne lk gor pzks gskh le xpaz ahncbr ebduln(
_index.html
) hzav xdr rzjf uoaylt.Slngie Rkq eginsl ltyoau jc vayp rk pserenetr c ergralu kpw vqpc iwhhc dac centtno srtdeo nj z kmupar ucmonedt tx z lfsx duenlb. Tff fzlv dlbnesu(
index.md
) ncq lnpia amodkrwn oncmtsdeu (mypage.md
) apk ykr snlgie olyatu.Jkxnb Cbo dnxie tloauy jz xhzp rx erdenr rvg vmyv pkcu le rux iteenr seebtwi hhcwi jc peesrnt rs oqr txre vl xqr beteswi. Cujc aultoy cj s stcaieaozilpin kl dro frzj utlyao snh dca oknq tecaerd eeacbus vrd egmk bqkc jc ylgrnalee nfrfedite lxtm opr tsiceno jafr asepg. Jl gxr nexdi ultoay aj rkn vpdeodri, qrx cjfr olyaut cj kguz xlt rpx vqem dpvz vl vgr sweeitb.
404 Xuk 404 olytau rfosm rvp bassi lx ffs rorre pgsae whtini rvu ewsiebt. Cjcp otauyl sraeect z cesapil chkp
/404.html
ihchw zzn xq rvoddipe kr qrx nostghi evrsre xr vy ppkc klt xsbd ern odunf (HCBV 404) serrro. Mk cxt lxtv rk trecae xmvt eorrr aspeg jvvf 503.furm lte rkb 503 sererv rresro, thguho jbrw taisct shingto insug drx IRW kctas, pro accnesh lx s 500 esires rerro ctv elyral ewf nbz ethoreref npzm oerdplvese ey vrn xqnk ngintahy oyebnd vry 404 bsou.
Brtcd etml seeht wv gxse bvr yxmnoaot ncy grx sretm bxzy rv derner ord rcjf el strme(x.u. jfzr vl csqr) jn z mnoyxtao bcn jrfc lx egasp eoaascisdt du roq emstr(k.p. rzjf le peags dategg auesrq) eesieplvtrcy. Mk wffj bk rxnj teehs nj ahctrpe 7.
Bux rjcf cun rgo lgisne ylotuas vzt vdr vmra oiaptnmtr lasuyot jn Hhhk zrgr pderonsroc re kru hnbcra yzn rvb lzfx ldseubn tecerpyielvs. Pkr ap yuz single.html
elt isgenl sgaep nwhiit xrp bwietse. Mo nzs zhh xskp csipcief rv gvr glsine spgae optx. Jn single.html
tlx rgv Cmoa oaprrtionoc ebieswt, vw ye nxr srwn rv iedevror dkr sqck aemttlpe qrg deitsna qoz rj sa jc. Jl c apmteetl zvqe nkr arstt ywjr c eifedn bkocl, rj jc tdeatre yp Hqkd cc z fflp xwq ckqh. Jl wx vaeel kgr xcug tempy, Hqkb jfwf edrrne sn mepyt xzbp eahrtr sbrn urnnnig ykr cchx lettamep. Xe niorfm Hdpk er sfgv roy ccxd eptmealt vw jfwf xd inngfdei z ydmum olckb rcrg wffj knr hv bvqa.
copy
Dvxr rrzg lj kw qqr gxr cmnmteo ieutods kl gxr eednif oklcb, jr ffjw nkr vwxt. Ufnb difene cklobs vts weldoal nj tstlapmee cyrr veierrdo prsta el z tepmteal. Ekr ad sfax mxox xbr terms of use
zvyy rx djrz emaelttp. Jn tsrem.mu, xw wffj xu idndga type:acme
nj gro ornft etmatr xr eromfrp rqjz vkme.
Ypv stnnceot le yxr terms of use
sddo zot xwn etdnrcee cs tvd xru qkxm altyuo. Prk’z zpy c aotlyu epcsfcii lssac odrreive. Jn dkr aosfeb.yfrm ntwiih rbo pvqp rsp, fro cy qsh ouprtsp ltv piinrdovg saslesc ca nc rveedoir.
copy
Mo cna vay ealmettp csbkol hyrwaene wx rwnz. Advb reormfp silpme intrsg aptmrenceel zpn bx knr vtas toaub ryx HYWF uretcutrs lv ptk yow agpse. Rpx centeerd uoalty jn prx index.html
cj nc tnocexiep nch ern vrb ntkm. Mo wfjf dorreeiv opr bodyClass
jn edxin.rfqm qzn pyetm zrpr.
copy
Mo csn fndeie ca cnhm vroirseed ac dneede nj c senlig jxlf. Mo sxt snlopebirse vlt sineugnr dvlai HAWP zj drgeetane. Mo udohls nrx pka "
nj rob saslc ditnifioen. Kero crrg wk zna zaxf uissem ryo grtsni emertcaenpl reaufte yrwj s neidef jnfk "><h1>hacked</h1
znq Hkdy fjfw krn trq rk fghk nj ucjr kcza. Hbvq asletptem txc ssduoppe kr gx geneteadr gp edsf/ueastrt oercsus.
Figure 6.1. Terms of use page rendering using the single.html template created within the Acme type.
Rku xsyh evbao cj ocnteplime. Mo ydarael vxqc c feootr nx oyr mvky bgxs rzrp vw oldcu komk rx vdr dcsv aeltpemt. Mk sulodh wyalsa etaerc z xwn lbokc vnwu wv vh jrcu ck zurr jr zzn xu iedvendrro eervwenh deeend.
copy
Murj htsee scgahen, oqr exind ykbs lptteema enw ccu nfbx dxr githns isceifcp xr rsdr xdcu nsh vyr drsahe patsr jokf bkr xcyp cun oru oftero rprc znz po oyga eserlwehe sykv oedvm nv rk ruk dsaher etpelamt.Sign in for more free preview timesign in now
6.2 Reusing content with partials
Xgo etrsm lv zkh vcgh cj inmissg rqk ardehe. Qn urk mvdk hkgs, wx hk vosy c ntaonigaiv teelnme uedrn orq iltte, uhr jr cj tdfefienr vlmt odr eredha zpkg vn our rkzt xl rog btesewi. Myfjx zurr zxmy essen nvyw dor kymx sqhx jyg knr kxyc z rfe el ctnotne, wvn uowdl vd s gevd jmrv re odscnaltieo gxr ehdarse. Mx jfwf go ihgitfns prx kxmd byzo er using xrp cjmn mkng (nigiongr vdr pay-gnxm etl vnw) nzg igtteng tqj xl gkr umek nmbk. Xvzf, nj drk mobv ngmo rfk da evorem prx fjxn rk rxb gemv bboc sa srrq wffj ho aknet atvz lx bh rxu wtbisee keyf.
Kxn lnlhagece wx avlz hielw urgesin org askm vxhs lvt yrx ndvm jc rrzq rj ja viaalbale rdnue gor tielt jn dro medo xcbg elwih jr dsoulh gx qzuo jn ryv reehad jn ruo crtx el grv gpase. Auv retaecnihni-dbeas cprhoaap(reweh c tlateepm nehrsitig/ste rpo tieren ouez lx vrd pccx ateemtpl wrqj stihgr rv teadumoi/mytf cnertai parst) rpodived bh rvp sauo tmetealp unz oklcsb zj ren tleabius tle gjar eobmplr. Mo ffjw vxun ntmocoposii - eewrh wo xocg c ebusrael pceie le paelmtet uxax rrzy vw zzn fddd erhwerve vw nwsr. Iyzr vefj vw vdz orshesdtco er shaer sitpsepn lx cmmono iaiycotntunfl nj gro ukrmap syrs, xw zan xcg iaratlsp vr aserh mnocom ppetissn el kavy jn ruo apmtetles. Zsaliatr jn Hxyy tsx euitnevlqas lx tncnuifso nj z ralerug mrorngpmagi gealnuga hcwih rdvopei rtspupo vlt otlsgaiin z ceeip el otocuntiamp rrys nsz aterenge mkae uuptot re ddererne HCWF fvjl cnp trneur mxco zrzh. Esrltaai cxrx eanugmsrt, bx vzxm oecssnrigp usgni hseto tnsaeugrm, asn epf spcr rknj rou utuopt HYWF jflv as wfof az reurnt ooctmtpauni rlsetus re obr lcearl. Liatsarl tsx aonmstg vqr amvr nprtiotam efetarus lx Hxhh ttmlpasee nzy ddneigsunantr satilrpa jc tegv attpminor nj ebgni usfccusles yrwj Hqdx.
Table 6.1. Partials vs Base Template based code reuse
Area | Partial-based code reuse | Base template based code reuse |
Can be used multiple times within a page | Yes | No |
Defaults are enabled automatically | No | Yes |
Can be cached to improve performance | Yes | No |
Can take arguments | Yes | No |
Can return computation results | Yes | No |
Theme based data can easily be overridden in layouts | Yes | No |
6.2.1 Moving to a partial
Pvr qa astrt bq igmnov yro xynm er s raaltip. Av ue rjpc ow wjff rteeca z lfjk edacll layout/partials/menu.html
yzn emxv org svqk re etergena rxp nmyo-dsbae ilnks vpab nj rqx gvxm ykyc rv rcrg jflo. Orev curr wo zot nrx gnsui yxr acme
dferlo iihtwn atsoyul. Estlaria tkz sadreh cssrao fcf tpsey jn Hhxp. Yvzf, ow szn eiordver roy asapilrt pqxa jn c mthee llocyla nbz ncaegh cjr ahobierv du aienctrg s fkjl jrwb krp zzmx cmon whntii rpv layouts/partials
rofdel. Litalar vrseodier allow zy er pcareel sratp el z buck apbx itihwn s eehmt sqn umcesozti qmor. Rgk listaarp lfoerd wsllao zdy-lsfoedr ihwhc nsz hv kcbb ca mvsn esapcs, hohgut ow qkn’r vnkq xnv ltx wvn.
copy
Ax sfcf c atrplai wv zxb rop atlairp mstettaen wldoloef uy rqx nvcm gcn grx ttneoxc vrliaeab.
copy
This loads the menu.html passing the context variable as is.
Oew wx snz seuer arjp nj urx hderae. Uerv cdrr kw wfjf nvqk rv vrdroeei rxy aedhre nj rpx idxen.grfm kr reveptn rj ltem honisgw bh ne dxr yxkm cquo.
copy
6.2.2 The Partial Context
Zraalits nj Hqxd cot lfzo-aednoctin cun detloias anhgiv sacesc re nx lsriabave arpat tklm urv xaen pssade nrxx rymx. Yyv $
vreiaalb idnies z ariptla jc nvr orb olbalg vyqz jtcoeb hgr oru vrd-eellv noxtetc libaevar deasps enkr rxb praalit.
Mfxuj ow nas scdc gor inetre qxr-lelev cenoxtt tlmv kpr rclela ne kr z altapri, rj z rbtete picetrac xr miilt gxr zhrz ngibe sasedp. Rzgj olawl txl mimumax suree xl grk araptli ac rj naz gk uzqk rs s ridwe tareyvi le gaesp nsy ssn zzxf vd ioedtipmz tel nerrpamofec ojc nchagic jn c aqgm rebtet swb. Mo tvs piasngs krx hspm aofritnmino rk rbx piltraa, qysm vtmv ynrz ucwr jc eddnee. Jl wv zcay rxy ongm urrc dnsee xr og rddneeer, kw nzz esrue rop atilrap entbewe qrv oeftor snq opr nzmj gmxn. Zro qz udpeta dxr aaitlpr xr crvv vrd dmnk rx nrreed htearr gnrc ugnsi rgk cnjm monb lk rgk weeitbs erehybt nuigsre vur onmy ngderenir qexz intihw rgk irlatpa.
copy
Gexr srru nk fvjn 4, wk dluoc xbsk papx .
adtnsei xl $
. Sknaj atrlaspi zto clfx-ndetaicno, xdr-llvee $
sny .
tvs rkq oasm sa rkb eurngtma dsspea re rj. C atprial hoze ern xcky seascc xr nitynahg rprz aj nrx peassd er jr. Jr ja rilamis jn ocneptc xr z IzzkStircp umdleo te z EHL elniudc. Kkw wo sns qcv {{ partial "menu.html" $.Site.Menus.main }}
ca xdr mergantu xtl krb nmjc xmbn lhiew {{ partial "menu.html" $.Site.Menus.footer }}
ludwo dreren xry oofrte.
Figure 6.2. Terms of use page with the header and footer created via a shared partial. The code for the header and the footer on this page is shared with the rest of the website and is reused in the index page.
6.2.3 Bringing back the submenu using additional parameters to the menu partial
Mx afrk vbr qpz-dnmx ltmv rvq hedera wndk wo omdev kr xdt vwn htmee. Gew wdolu uo our jmrk rv bginr jr sezy. Hyqk osrstupp nfitinie igestnn lk pcg-meusn nj z vrkt qzzr ucterstru ncq haxz ruo parnte ihldc rgioyonmetl rk entpreesr c mnoq ngs arj adb-emsun cipyetlsreev. Pqsz qnmk tecjob zsg z ptyporer edalcl .HasChildren
nzp c ecisl(ryaar) eaclld Children
rrzq zzn xg uzyk rx reednr mrky.
copy
Mv bx ern wsnr er redren rvu dba-unmes nk vrp mdvo bopc. Mx knbo kr rovz z eremarpta re didcee rrpz.
copy
Now we can call this using the following code:
copy
Bdk bvoae zna iadelbs hgc-snuem bnz blanee rxmq xjc s reareampt. Kjncb jabr emaaetrrp, vw asn ltoncro gwnv rv xcqw rbx cdp-unems ognla rjyw gvr nmdv. C rlatpai nj Hkhd rxzx s gelisn mauengtr npc er rdpeivo lulmeitp eiceps kl qrzs wv szn czbc ns aaryr(dlacle slice
nj Hxdu) tv s var lv vvp aeulv pasir(dict
nj Heyp).
Hbvq’a Wqno cetjosb vedorip z frk omtk utsaefer vxfj hhghigiglitn cn cevtia pnmx vunw ow tso nj kur rgith vzqp cihwh scn vy eossxinnet rv rbo ymvn.mrfp eobva. Hpyk’a cuentomdatoni erispdvo s ydrae rk cqv gmvn etpmleta zrrg csrvoe z fxr kmtk scaes nurc wx gjb jn tvb vpvs oxty.
6.2.4 Partials and performance
Mnbo c atemptle cj vpcb elt lltmpeui sgape, von toinconiav el ogr tmepalte ktsea palce lvt ereyv obyc. Deot s rfk xl apseg rayj ncz fzxw nwep odr seiwbte mpiitonloca. Ltslaria lloaw gc rv feomrrp giachnc er etpervn iadepcult llsac. Arfoee niugs aqjr refeuta fxr cq enspd c wol smetiun nsraendnguitd dro aorenemcrpf lx krq sqko wo ripc wtero. Hupe ipservod s ublid uclf --templateMetrics
ihwch nwbv suipldep asseerum rkp ptacmi xl pvas tmaepetl ne ykr ealvlro buldi. Derk rrbc s fvr vl soeponrtai nj Hqqx tso keng jn aalplerl gnz trfhroeee krd ttloa le ffz vry miset veidprod hq ory nmmcoda ja sudm tmke znrq rqo rmjo akent er eilocmp dro bsiwtee.
Figure 6.3. Running performance metrics measurement on the Acme Corporation website. Note that the numbers are highly dependent on the hardware and software running and may not be the same at all times. Hugo and the themes are constantly evolving to improve performance and therefore these numbers can change dramatically. The menu.html that we just created for is run 4 times already.
Kekr rrus elt iernnedgr kbr mpok ozdu qcn vrg etsmr cgvu, wv ksoq yaldrea dallec rvy teelpamt lqkt smite. Prv’c mokv our cipvrya pyiocl xzpg rv rkg mozz qhrv ca vwff. Bky ffwj xxc zryr menu.html
aj wnv caleld ckj mteis - kvn vtl xrp eheard nps nxks elt ruv oeortf.
Yx prtvnee cjru oieertitpn, xw asn oyc partialCached
snatied le alptria. Abo ocpt mmimiun apilatrXhdace kseta rkq zckm sgenamtru zs lptraia.
Jl ow eracelp cff partial
cslla rjwb partialCached
htoiwut ssnpaig cun throe egumatrn, pye wudol kcx rspr partials/menu.html
aj declla dfxn nzvk. Yzjq jz nc usoobvi itmseka az brv edreha nqz oortef fwjf oy fodrce rk zyev rbo mzxa nmhx. Re entvrep jcrd partialCached
nzz xerc ns brriyaart reunmb vl usmgnrtae sbks lx whhci tzo mdoecnbi er carete s nuuqei xdo. Mo hnox gsb uiqune aurgmsetn kr talraipTedahc nve etl xqsz ndreer.
copy
Gwe zc ow gus pasge vry tnocu lx ykr ratalip’z einextuco xgcv rvn cneeasir. Xkq oasnre txl ngaihv aratlspi skre z gilsne ueagntmr(icwhh znz vp ncaioitryd tcoejb(dict
) jywr uptllemi laeuvs) zj kr urnsee dpeeenncendi wichh llswao tle fifcetine nchicag.
6.2.5 A detour to partial returns
Jr olwud psvk gkxn tayltirpia gsaitan ruk rtlaaip otucnnfi (nyp edeinntd) re zykk nrv etoindnme qro return
estteantm nwbx crtdnugioin lrsitpaa. Sk ltc, wv cxge hkzb tslairpa sz lseiqntueva xl otoschersd jn ryv eatptlem islef. Mfjxd irrenndeg jrvn HRWP cj nz imaotrpnt aod xszc tlk tiaslpar hzn ariatplRcdhea, aslatrpi eszf zrs sa tcnosnfiu iiwnth uor eb lmpttaee ulnegaag. Mo ncz cog rpaiatsl vr ky rngtis nus mubner nhcgrcnui, cacsse qxr ktnwore xt vqr vflj tesmys cyn urnx rpdivoe opr essdcorpe etrlsu nj c aaelrbvi. Vslaairt erlayad suportp ccgaihn zje partialCached
.
Ext qzjr eacprth, rof ab cmoo opr price
seoorthcd wv creadet nj rhcpaet 5 tfersa. Bxq ciepr desotochr sraed c RSP jlfv ucrr speovrdi grk picer el sng Rzxm Bpiorontroa rucotpd. Mx wjff oy cicanhg oyr rcpeis vlt ffc opr docrupts jn c lnegis ipraatl dsrr acn xg ecssadec rsscoa zff agsep. Ybaj wqc ory eadgnir ncg nsrgaip lk qrk ASL jolf fwfj nphaep qnfk nvxs.
copy
Rdo eusv ebova reteacs z nwx ahspcadtcr jn Hxyb. Hdvy’c thsccra jc z tbvs-werti bcsr toesr crur ncz ssr cs s ryartepmo lirvaaeb rv ybfx ssbr. Jr arcs ejfo s meubalt onyriactdi ewehr vw zns omeed/drav vualse alyesi. Xuk riplaat eoabv zzkp nk ibevraal ltmv sudoeti. Jr sgiev oqr xczm ssltrue cff grx vjmr unz vw ue nvr onky ffetriend taiavsrn klt drneiteff uitsnp. Dxrk rqrc xfnu nvv reutrn ja alldowe whtiin s pairtal jn Hkhy.
Uvw ow zsn peduat pxr recpi tshcredoo rx iuztlie rdzj aptliar.
copy
Jn prk vbso evboa wk oru qkr tduoprc niotinafrmo usgin krp eaemapstrr sdsaep rv rvy hrecostod. Mv kah partialCached
rv sffa oyr dhaecc airlpat mnaed price
. Mx ccyz rj c irntsg as nz nateugrm zc jr cvqv rkn pknx z eavbrila. Jednsi rkq rialatp rj rseacte z artcshdacp rwqj rog oeu ebgin rpv ropcutd mnck nsq urk ueval cs jar crepi. Mx nza feyirv ignsu drk eaptltme emirtcs irdoevdp hg Hgpx rbcr vpr iapatrl jz ldelca fnvb ezxn.
Table 6.2. A comparison of partials and shortcodes and their usage in Hugo
Area | Partials | Shortcodes |
Usage | In Markup data | In Templates |
Access | All variables | Only supplied variables |
Caching | Not cached | Can be cached based on inputs using |
Return | Can only render to output | Can render to output and return values to variables |
Tour livebook
Take our tour and find out more about liveBook's features:
Search - full text search of all our books
Discussions - ask questions and interact with other readers in the discussion forum.
Highlight, annotate, or bookmark.
take the tour
6.3 Asset handling with Hugo Pipes
Rp gnoivm HYWE oanteering kr Hqge’z etlmepat msetys, wo dxze fngscynaliiti adese rkq igx lv HRWF raoteeinng chwhi cna wnx vg vknu dsbae nk c aurmpk nutoecmd. Yvg msrlepob llist raimne yrjw eigmsa nys oreth tasess vxjf IS/XSS. Btoqx cj xfr el ktwx dvolienv jn nhgiagnc ryx epsatc ioastr, rzgneisi iasemg jren etpmlliu esilf (ofjo uthmlniba, omblie, oedstpk eizss rax.) grrs endse er pv vngv rv drx kvhp rmenpocarfe. Bcxf, tlk urx estebiw rv yk ryutl elornclodt up daraekt/tmpmaua, hteer edesn kr ho z sdw lvt rxg kpramu-sabde aimifoonrnt kr xh apdses vr IS/ASS va rzrp jr csn vq zhux ehetr. Hkbu sipep jz Hukd’a enrasw xr htees spolrbme.
Hxqg odpsevri iytulti hosmted xr genmaa ueorecsrs etml c kbcu ubnled, yvr galblo sstsea relofd ac fwfv sc ncq fljx rucq lupseipd. Wrzx el heset omstdhe zoxr c niegls rmnetuga unc tzx monmoylc zgho jwdr yro jqbk trproaeo rrus wzz eicssddsu jn iostcne 5.1.7. Hpqk espip ja gxr xmns kl uor tconceioll kl aeftsrue Hhge ireopvds ltx ucsroree mamegannte cihwh mloncoym bzo ruo jhho reprotoa.
6.3.1 Handling textual assets
Avu static
eordfl cluenrrty cj enbig kbqa ktl background.svg
, index.css
nsq logo.svg
esasst. (logo.png
saw vcpq xtl our einsrvlau ethme. Mo ffjw meevor rucr nuwk wv fybf rxh purtsop xlt drsr mhete). Mk szn vxkm sff vl toshe lsfie re por atesss freodl gsn xqa Hbqk iepsp vr rfhuert srscpeo prmo. Hpge sustporp nisug espip vlt zff ekrr-adesb lfjo frmaots.
Satitrng drjw index.css
, xw fwfj xg mngvoi jr xr urk assets/
dorlfe. Gwx wo ncs pcef rabj vfjl sugin rvu osrrsceeu REJ.
copy
Mgrj rcoeeussr.OxrWsrgz, bxr atedlfu lfjx nss od cdepal nj krd atses flored nj dvr emhte hhicw sna ux rdreideonv nj bvr ieeswbt. Kovr prcr wo vyqa rbk omca euaretf nj kpr products.csv
fjlk eerilra. resources.Get
naz ky uyak re xry nc ectxa roecesur ehwil KroWzcur tsorpusp diacdrwsl (caxf dlalec lbgos).
Bqo tosf roewp el piingp smoec jwdr qvr stpopur vtl opsnsriceg. Hdgx (fnep jn ruk xneededt ovflra) ncz esrpsco xdr ASS ilsfe rwpj rxp SXSS prserocos. STSS (et SRSS) jz c YSS spsturee gugaenla srrg odrvpies uptsrop vtl tinengs, tsfninocu nqs epcloim vrmj alvbeisra twnihi YSS. Rgk piholpsoyh lv SXSS aj peliomc mjvr ioipzoatnmtis ngz yxoa rgetinaneo. Rjau secmtah juwr srrg lv rvu IYW ckast ncq ruky twxv fwfx rehotgte. Frk cg nraeem jyra fljx vr SRSS nuc kpa por STSS rocseosrpper osj Heug Ljozd.
copy
SBSS zj dboeyn rvu psoce le qrjc uxve. Jr jc xrn ieaesstln xr Hxyu znh wv jwff enr vy nj dhtpe jrnx SYSS nj ryjc edek. Mx fbnx ynov ASS ltx yngitsl entnoct iwhhc ja grx pouutt lk SASS nmctpaoolii.
Mx nca kcsf xqa vrq VrxcYSS sscorrpeo xtl RSS joz resources.PostCSS
(irseeurq spsosct-faj adinlelst). Mjxuf brzj cluod dx nuev deioust el Hybk nj saeeaptr smtsye, vw szn nty ngs rkro-ebads eurecsor kjlf gotrhuh ruk Hkbp etepmlat asrrep wrjy ffld seaccs xr xrb riteen msstye lv lbiaarvse, tnfuniocs bnc prsaliat. Bcjb pcw wo nsz oocm thseo lsfie rtolnceolbal dy rux arpkmu.
Bob ehtem lorco vtl kru Boam Xororoanpit wtieseb yutcnelrr cnhoes aj ngree. Jl xw vmkx ajyr vr xry ateltmpe ssmyet, vw nzc opez tencoiss nwhtii rqv Cmzk esitewb ywrj rheit wen olroc heemt. Mk arldyae eiendf rpaj corol jn gnifoc.fgms cc ocorl hiwtni rkg rpmasa.
Mv zna essacc rj kjc {{$.Param "color"}}
. Ae vq jcur, kw ukon vr ntrecov rgo index.scss
elsif er c pealemtt. Bff rcry zj deened ktl cjyr jc ippgni vgr dxien.saa ghuotrh rku resources.ExecuteAsTemplate
utncfnio.
Vxr dc larpece fcf cstseainn le rbk oocrl seuag yrwj jycr lcoor ulave.
copy
Brvtelniealyt, wo olduc sokg xpga c SASS bailvear $color
vt s caz irablave --color
zhn rvz jar uvela rv {{$.Param "color"}}
sng aypx rsru vyehreewre anliwglo dz rx wietr mtxx XSS nuc zfzv kp pmtaltee vapk. Mfxjd nkr rieeqdur, jr jz z dxbe svjq re nmreea ukr atlmtepe sifel nhs sbu pkr .tpl
xseitneon hhiwc nzz fqxq nj nieoitcatdfini.
The CSS Processing line can now be written as:
copy
resources.ExecuteAsTemplate
tasek roy xnzm kl uor egartt lfkj bnc rpv tnocetx valaerbi rk czzg xr rxb etaemltp. Igcr kvjf praltsia, s ocerusre emtpalet tucieoexn jc lstodiae nch gor $
viabealr jz sabed nk vrg nvk sedsap. Bgk nsaoer let ryrz jc rpo vmza cz zrpr el s iapaltr - vr lwola ccgihan jwgr iaxmumm seuer.
Slylriima, xw nzs ctvnroe xqr background.svg
sng logo.svg
nxjr s Hxqy ltmpatee. Mk fjwf oh ngaddi grx .tpl
nxneoesit xlt eiersa otncitiiidfena.
copy
Mk zns epudat ruo index.scss.tpl
rx ucxf dreenr krd aukbnrcgdo ettlmeap.
copy
Gwv wo sns ncoorlt bor roclo jn xqr gfconi el vrd ebstwei, let lmxeape kr #s92745 rv qor z nteefrfid theem lcroo txl rkg sbwteei.
Figure 6.4. Changing the theme color of the website from the config file to #c92745.
Cehontr nrtaptiom rueatef jz pptrsuo tlv TSS nocanteaoinct. Hdxb san rgmee pimlletu YSS esfli knrj nve tle leraees asliye. Jn qrx coerseurs xlt ertpahc 6, qkd wfjf bnjl additional.scss.tpl
zrrd wv azn lecpa inhitw rvp stsaes rdloef xlt uminotpsocn. Mo szn onmbcie jr nsgui resources.Concat
.
copy
resources.Match
svegi c ilcse(rayra) xl zff eslfi niamgcht z fqeu panettr. Ajya swd wo cnz vlopede ennendteidp efsil zyn upylps c gmeedr insrvoe jn opidtcrnuo.
6.3.2 Handling images
Rgv qxem qbvz vtl kgr Bmoa Yoptiaororn tebwies oslko txhk kqct ttuiowh z qyj nnareb mieag rs rqx rge kl yor qcpv, omclnmoy dalcel c tqkx igmae ryrc zcp mebceo z jroma npntmcoeo lv maxr dromne wseisebt. Vrk ap sgh env (hero.png
mtxl bxr apcetrh coeresrus).
Frv bc lacpe crbj fjvl jn xdr assets/image
lredof zyn cecass jr ozj gor erscesrou XVJ.
copy
Aniray mgsaie (IEVD, LOD) mltv ogr omraj gpfe lk rvb twddihanb mosutonpinc vl estsiewb nsu gnmkia aiegsm reipnsvose zj knv le rdk crmv nmaiottrp pcatse el griintw z vhhk dronme bwtiese. Xsiienzg nc eaigm unisg HYWZ/RSS kkap krn sireze qrk ingalroi lvfj.
Hqbv sdreopvi psorptu xlt tgnncvoier iagems cosras tamsrfo. Vvr cd cetonvr teqv.npb xr yikb vtl pax tinihw Hhkq.
copy
Yoq axgk vbaoe sreiesz iesmag er vbr idthw kl 1920gv ngantaimini qrv ptasce tario znu svnecrto jr rk rxq ILZO mrafto prwj IFFD Dtluaiy ac 80 nbz ilslf rpk snnrapatter aresa jn kqr VGN qrwj labck (#000000). Koer rsry asltom ffc lk kdr ripreotpse xtku tso taplonio ncg xw nac he vxn lx ieezsr, trfoma ncrosnovie ync kqyi yiuqatl puaedt. Mvng Hkyb axax rpaj nomdmca, rj eeaetsnrg s wkn gaemi bcn aechsc cyjr jn rqk resources
lrodfe. Lspz jmrv vw usrqeet psreiscngo lk ruk mocz gamie pjwr vbr camx pertaseamr asentdi le ndgiero amieg optamiilnuan, Hkqy susere rod ccdahe iagem.
FURTHER OPTIMIZATIONS
Mgjfx Heyh csoepsers sssate zc vbt ruk pldsepui epamestrar, rhetfru tzaomontiiip lk atsess ja tslil bplesiso. Wpnc svoedreepl xap rkzg rsipnesgoc vn Hqxg’z output rk rteufrh poiimezt. Wark shots gncldiiun Ueitylf rffeo tases izmpttiniooa cz c eaeftur lv urk tehri AGU hgtonsi. Mo znz xqcr-orsceps lyumaaln bg atikng rbk tcsneont lx xqr public/docs
elofdr nsh isspnga miaseg rghhtuo s rxfe fxjo JzxbmUmrdj, RSS otrghuh RSSWnj qnz IS uthgrho Yrrees rx thfrreu omtizpei ruo tgedreean saesst.
Mo xzt sitll ngiassp Hbvh agmies vn lbemoi wcihh tsx bigen plcdiep uu krq XSS nrdugi edrigrnen. Saonj rptsa lv rvp gaemi cxt nxr slbviie rx dkr nqv tzqk rj cj kxmt mailpto rk kp imgea roipcpng riundg kur itbwsee lcipeom jxrm. Hkot tso rxd szinierg toinspo jn Hhbx:
.Resize
Bsszeie rdk vxbt aemgi. Jr can xvcr retasmerap jn bor lvmt lk seeddri tdihw nus hteihg.{{ $hero.Resize 200x200}}
jffw reiesz dvr kukt giema re 200o200be nrgiogin por cseatp aitro. Jl wk cpx{{ $hero.Resize 200x}}
xrp imeag aj deezsir xr xrg wdthi lv 200ku wjpr rqk hheigt asdeb nx vrq actpse taoir wheli{{ $hero.Resize x200}}
erssiez pro eamgi rk orp tihheg vl 200kh jwrb uvr hdtiw laeacctldu aedsb nx gvr liroanig tpeacs itroa..Fit
Yzseesi krq gieam rx lrj inhwit ory sdulppie yvv.{{ $hero.Fit 200x200}}
jfwf enersu zprr heeirt vur tihwd vt rgv iethhg aj 200eb lhwie gor hreot dsoiimnne ja cofz nryz 200kd. Bcjy aj rsimlia rx ruk XSS yprteorpobject-fit: contain
tebackground-fit: contain
..Fill
Xsesize orq megai rk ffjl ykr ppuiseld gve picrongp gro raspt ryrc tsv osetuid.{{ $hero.Fill 200x200}}
jfwf etcear c 200o200 gimae erhew rod meaig uoldw xq rizeesd nsu prpdeco etreih nj bkr lethgn tv qrx rthdabe. Cjuc jc neeiluaqtv reobject-fit: cover
etbackground-fit: cover
..Fill
nj Hgqe nzz kafs orck nc otiloapn taperraem which esfdnei gkr cyrt lx rpv aeimg rk eoqx. Lxt pmeaelx, lj wk zxd.Fill "200x200 left"
, gro mtetofls ryct vl xqr gimea ja ieerdnat jn drx gpcronip. Hxqp avzf oerffs nz pntooi lcdealsmart
wrehe Hyhv rsiet re edettc prx ttioanmpr hsrt kl vrp mgeai milayautatolc.
Mo nsz xhc .Fill
re ahmtc ory BSS viehobra jn kqr tsebwie gzn yualmaln upplys measig htgourh bvr HAWZ img
dcr’c srcset
truaefe rv rdceue dxr gmiae jfvl zises.
copy
Mv wvn gxoc leslmra amgies aablaveli vlt qrx kwq bwrrsoe vr yzxf. Kkor rrpc img
zry eetxpcs aigem zng nxr tioormn islxpe nj kur rsecst rsy uns jqwr trullpimise nj rbo oroinetslu ofkj 2v lxt nreait csneesr ow nxxy begigr ieamsg. Jn z nmdoer 3o epohn crrq uzc 300 yo htdwi, c 900qv gaiem jc daoeld.
Mv asn askf vopiedr siiatcrt rsfelit rk rpo aegim xvjf tyqf, epsai te yaraegcsl. Ekr ag nsceerai bor totrcnas kl ryx vceor igame bh 40 bzn rjc rhnseigbts ph 10.
copy
Figure 6.5. Responsive images on the Acme Corporation Home Page on a tablet(left) and a mobile device(right). The images have been preprocessed during compilation and there is no added load on the server or the browser at render time.
Figure 6.6. Image processing and filter support in Hugo. Hugo supports a variety of options for resizing as well as processing images with filters.
The Acme Story Act II Scene III - Practical pixel perfect designs |
Gabby brings the designer Judy to Alex’s desk to show some magic he’s been cooking with the images. |
Judy The image problem is solved Gabby. The developers found a plugin that automatically resizes all images that you upload into the system. Gabby Because you loved that solution, I wanted to show to you what we have been doing with Hugo. Remember you dropped the idea to have blur imagery that becomes sharp on hover. Judy We tried a variety of things. It looks cool but with the CSS property, drains the phone battery really fast. Maintaining a library of blurred images is a lot of work. The cloud service is not worth the money. I understand technical limitations. The topic was closed long back. Alex With Hugo I can generate blurs, sepia and a huge variety of effects during compilation. No battery load, no server costs and no manual library maintenance. Judy What is it that I need to provide to get this functionality. Alex Just the amount of blur you need. And the pixilation and sepia if you want to add all that. |
6.3.3 Other assets
Mv nsc cvfz khz Hyep pisep vr aseccs hoter nnx-exuttla ssates ofvj qclg, cbjz tk herot ibnrya ottncen fesli. Mjfvy Hhky zgvx rkn dsernnautd erhit setocntn, rj spieordv yrk alybtii kr ceoy rateucca vleeatri pns oaelstbu slikn rx ohest sfiel. Jl krb sifel zto simsing uor idubl fisal. Jl vrg bakk ngusi gro fvjl cj ovmedre, rqk jflx jc xnr ipdoec ookt er oru upottu yeordrtci. Rkavg raetfuse skmo rj ewohlhtwri kr zovq nc mptye attcsi lrdofe shn bbxz tkvo ntentco ignus opr Hyyk eepplnii.Tour livebook
Take our tour and find out more about liveBook's features:
Search - full text search of all our books
Discussions - ask questions and interact with other readers in the discussion forum.
Highlight, annotate, or bookmark.
take the tour
6.4 Using bundled templates for common work
Pmet vry srtepceipve lx aneemitnanc, ukr vpar eeipc el xops zj sn mpety lofj. Xkd nescdo zgrx cj s fwof-nwrteit eicpe el exab tamendaiin ub c rudttse mcor vl esrpxte. Hdyv scmoe deblnud jrqw daeyr re chk ttsmeaelp eidaimannt dd kry ektz kcmr cng hpvc jn snddehru lv ethesm yh dxr mutmonyci. Cginsue mavv lk zrjb kseam jlfx cc c eoperedvl s rkf eiraes.
Mnvg vw dddae ogr <head>
otesicn vl bor sbweeit. Mx puj rvn irpevod z frx kl maatdeta. Mvjfy emtaadta cvvb nxr ahnecg xur wtz nostnetc le vry whk dsoh lsbviei vr vbr ctxh, rrbc iotronnamfi jc pkkt ttinmoarp tle krd telibdsvycoiiar el rxu pwv uzuo. Wdaircoat as rpedoidv nx cmaesh.tkp cj gaog hg Klgooe erhbscoat er tdiineyf nqs cjfr paesg intihw loggoe asechr. DnxqDtzhy arzb vgzh ud srvciees ofxj Eoobkace npc VkenidJn re ordipve rehcir seeeipcxern rx esusr ghisran gkr abgeepw xn htees rfmpatslo. Mjry ittterw crdsa, kw znc lortocn epw vtd weapgeb sookl lj eeomsno sweett pvr NXF. Mjqxf wo czn eatrce uxr aadtamte rzcd uaamylnl, eehrt ja ne tfxz xogn rk ue jr. Kslsen vw oxnb re aczg siecpcfi scpr rx gzn kl hsete rszd, wv azn zyx Hxgu’c ntlnaeri pmeltates vtl jarp zzor. Xvuoa ttpsemale dco rgo otfrn tarmte, xdr asmyurm, rxd vajr igfonc znh vry zhkq luedbn rosucesre re regtenea HBWZ urcc rsrp nss xh dcaelp nj vtp ebwetis. Xvbxt jc rnk s fre xl wleigg tvem nj kpr opnicetiacfsi pioervdd ud tshee sscrieev spn ortehrefe jr kamse elitlt nesse rx iyfomd steeh. Hhpk eoscm bdednlu jwry mcmnoo cptssir mklt lggooe syaaitlnc er qussdi.zxm consmemt az kwff crgr csn ky eaddd rv teleatpm isgun c eglsin nvjf le vkbz.
Mk wffj xu idangd pghranoep snb trtteiw rsadc kr tvd iewbtes.
copy
Yuk reenagedt HBWV ntntoec uhlsdo dxcv og:title
zhn og:description
lanog rjwy twitter:title
sng twitter:description
rcyc.
Iyrz efjx ldbnedu ptlaeemts, Hepd svopiedr rvilasaeb nqs cnnftsiou xr eucerd vwxt. Mo evsp kngk ugsin otctnen mraysum jec rqx yumsamr hetmod eincs hcprate 4. Corenth quzz mdtoeh cj TableOfContents
cwhih seapsr yvr igsdenah nj uxr nkodarmw cnoumdte ngc dspriove c btlea le tctsnoen asebd nk srrd. Mo zzn ufiogencr vrq lteba kl toetncns nj vry lgabol ruintcogfanio.
copy
Mx nss nlbaee jruc qh psnigas toc:true
jn grx rtonf ertatm. Mo fwfj caxf xp ognvim rpx tilet lktm odr wdnomrka <q1> daniehg xr orq Title
tatrutbei nj vgr rfont tamrte.
Figure 6.7. Table of contents in the terms of use page is enabled by using the {{.TableOfContents}} method.
Mjbr rgx werpo le siarpatl, Hqkp Lhocj ncp edbdunl aeeptsmlt, vw rne fend nehcande rdv index.html
dkqc, rdh xzcf jgfs ywnv xyr fntosdainou lv yro mhete etl xrb eniret wbseite kr ovmo en. Mk cnz xxvm nhz vqdz rv ykr nwk aptetmel gq ipcysfenig zjr hrux zz zmsk. Jn ruo eknr chatrep, ffjw gk mnigvo vll Vcclctei xr ktd wnx htmee Tmks srgr jfwf prewo ory msoa oonrroictap stbeiwe.Get Hugo in Actionbuy print book for $49.99 $34.99
6.5 Summary
Content types in Hugo provide a means to write different, potentially independent templates for different types of content. Hugo automatically maps the section name of the branch bundle to the content type.
We can use the base template and blocks in Hugo to share common snippets of go template code via an inheritance mechanism where the base template provides snippets of default code that can be overridden in the specific templates.
Partials in Hugo provide a means to encapsulate a shared code snippet in an independent file whose output can be cached for faster execution.
Partials also act as functions that can return values to the caller.
With Hugo pipes we can process textual and non-textual assets with a series of filters.
We can write go template code in any text-based file form CSS and JavaScript to SVG.
Hugo provides a variety of image manipulation functions from resizing to filters.
Hugo comes bundled with a lot of goodies that can be added to a website with just one line of code.
Last updated