55 < meta charset ="utf-8 ">
66 < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
77 < meta name ="color-scheme " content ="light dark ">
8- < title data-pagefind-weight =" 8 " > {{ title + " | peps.python.org"|safe }}</ title >
8+ < title > {{ title + " | peps.python.org"|safe }}</ title >
99 < link rel ="shortcut icon " href ="{{ pathto('_static/py.png', resource=True) }} ">
1010 < link rel ="canonical " href ="https://peps.python.org/{{ pagename }}/ ">
1111 < link rel ="stylesheet " href ="{{ pathto('_static/style.css', resource=True) }} " type ="text/css ">
@@ -55,7 +55,7 @@ <h1 data-pagefind-ignore>Python Enhancement Proposals</h1>
5555 < article data-pagefind-body >
5656 {%- endif %}
5757 {# Add pagefind meta for the title to improve search result display #}
58- < h1 data-pagefind-meta ="title:{{ title }} " style =" display:none; " > {{ title }}</ h1 >
58+ < span data-pagefind-meta ="title:{{ title }} " data-pagefind-weight =" 10 " class =" visually-hidden " > {{ title }}</ span >
5959 {{ body }}
6060 </ article >
6161 {%- if not pagename.startswith(("404", "numerical")) %}
@@ -78,13 +78,20 @@ <h2>Contents</h2>
7878 < script src ="/pagefind/pagefind-ui.js "> </ script >
7979 < script >
8080 window . addEventListener ( 'DOMContentLoaded' , ( event ) => {
81- // Initialize pagefind for desktop sidebar
82- new PagefindUI ( { element : "#search" , showSubResults : true } ) ;
81+ // Ranking configuration to boost exact title matches
82+ const searchOptions = {
83+ ranking : {
84+ termSimilarity : 9.0 , // Higher values favor exact matches
85+ termFrequency : 0.5 , // Lower values reduce penalty for low term frequency
86+ pageLength : 0.2 , // Lower values reduce the impact of page length
87+ }
88+ } ;
8389
84- // Initialize pagefind for mobile view
85- const mobileSearch = document . getElementById ( 'mobile-search' ) ;
86- if ( mobileSearch && window . innerWidth <= 640 ) {
87- new PagefindUI ( { element : "#mobile-search" , showSubResults : false } ) ;
90+ // Initialize pagefind for either mobile or desktop, not both
91+ if ( window . innerWidth <= 640 ) {
92+ new PagefindUI ( { element : "#mobile-search" , ...searchOptions , showSubResults : false } ) ;
93+ } else {
94+ new PagefindUI ( { element : "#search" , ...searchOptions , showSubResults : true } ) ;
8895 }
8996 } ) ;
9097 </ script >
0 commit comments